i want to know where can i put the "library" folder in my zend project. Presently i have it in the location of my Zend server. This is my current "library" path:
E:\zend\ZendServer\share\ZendFramework\library
And here is the path to my "app" project:
E:\zend\Apache2\htdocs\app
Inside the "app" project, i have the folders like "public" and "application".
Now how can i integrate the "library" into my "app" project, without referencing it from zendserver?
The easiest way it is to put those library files to the library dir (as in the other answers), but you should consider keeping them separated from the application.
It's easier to have separate git or svn repos for the libraries. Easy to update and maintain for multiple projects at once. Putting them in library will also won't work if you installed the libraries from the bundle, e.g. apt-get install zend-framework-library.
To have the libraries in any directory you want, just add it to the include_path array in the index.php.
Quite often, you'll see a folder called like "lib" or "libraries" in your application (next to public, application, ...).
In that folder, you'll put the frameworks you're using.
For example :
public
application
libs
Zend
Doctrine
...
To get Zend Framework, just download it, and unpack it to the right folder ;-)
Advantage : you'll be using the version of your choice -- and not the one, possibly outdated, provided by your environment.
And, as a reference, you might want to read the Installing The Zend Framework chapter of the e-book Survive the Deep end.
In your app project u should have a library folder and should contain zend folder in that..so just copy library folder and put it in E:\zend\apache2\htdocs\app.
Please don't tell people to deploy 3rd party libraries to their application project folder, it is bad practice. Deploy your libraries to a path that you have access to, which is outside of your project, and reference it in your include path.
During development, it is fine to have the library in your project, for reference sake, but exclude it in your deploy script and instead have your deploy script either set an environment variable, or have it update your include path.
Related
We develop in PHP and HTML/Javascript.
Over time we developed a very big source code library, that contains a couple of hundred PHP and Javascript libraries, that we use for every project. The framework resides its own svn-repository, that we include with an external svn link in each project.
The problem is, that the entire framework itself is about 800MB now.
With only a few projects that we worked on, this wasn't really a problem, but now we have about 30 projects, that all contain a FULL copy of the framework, which takes up a lot of space, and requires constant updating of each copy.
Somehow I would like to have the framework outside the project folders. I've read about referencing other projects in Eclipse, but couldn't really get it to work.
How do you setup the include paths so that each projet 'thinks' that the framework is normally inside the project folder? And can you make a virtual link in an Eclipse project to edit files in the framework just as you would normally do, and get code assist for the libraries too?
One of the main problems is that all our code (and some libraries in the framework itself too) relies on the fact that the framework is in a folder 'framework' inside each project. I'd rather not change all those references to a different path, so maybe I need some .htaccess trick to make this work...
Does anybody else follow the same procedure?
Any advice ?
can you use the "big" project as target platform?
why-create-a-custom-target-platform
If you define it as target platform, the sources are available in your workspace, but they are placed in 1 folder for multiple workspaces. the workspaces will link to the platform, but will not check them out.
I know that to experienced ZF developers, this may sound silly, but please bear with me. Let's use our imagination for a moment and say that I have a hosting package on a Linux server which does not give me access to the any folders outside of my htdocs folder (or www or public_html folders, whichever).
I know that all of the instructions recommend I install this framework outside of the htdocs folder for security, and set an include path in the PHP config to automatically give me access to this framework in all of the PHP files.
However, given the above constraints, this isn't possible. My questions are:
As far as how the framework goes, can I install this framework inside of my htdocs folder, say, placing it in its own dedicated folder at the same directory level as my application, and forbid public access to it using .htaccess?
How secure is this approach, if I set Apache up to deny all non-local requests to this folder and its contents?
Which core file(s) do I include in my scripts to give me access to the framework?
Sorry for the crash list of questions, but I have almost zero experience with the Zend Framework.
Thank you for you time.
You can upload the whole Zend library to your server. Best to place it outside your htdocs folder.
Then you use this line in your code:
$paths = array( '/path/to/Zend', get_include_path());
set_include_path(implode(PATH_SEPARATOR, $paths));
Then you can use all zend just like normal:
require_once 'Zend/Controller/Front.php';
Zend_Controller_Front::run('../application/controllers');
Why do I have to configure an include_path when installing Zend Framework instead of just manually including? I've never done this before and can't really see the point, also I've spent some time trying to figure this out with no luck hence why I ask.
Actually I add Zend framework to the include path to be able to use Zend tool.
If you want to create a project structure and add controllers or models or even scripts using Zend Tool you will have to have Zend framework added to your include path.
Another reason you may want to ship your project without the library itself so that the end user doesn't update the framework version himself and break your code.
Also if you are working on different project at a time you may want to keep only one version of the framework shared between different projects. This is handy when you need to update your version of the framework without going through all projects every time.
You don't have to set your php include_path to include the ZF library you could just copy the whole ZEND directory into your applications Library directory and continue on.
But a lot of us are working on more then one project or don't want to have the library in our application so we add it to the php include_path so php and our application can find it.
Now if you are refering to the windows or linux path, those are required to use the ZF cli components ZF.bat and ZF.sh
When modifying the Include Path you can use Zend Framework without knowing the Full-Path of it. You can simply use require('Zend/Loader/Autoloader.php') and PHP will search in every include path.
For more information have a look at: http://php.net/manual/en/ini.core.php#ini.include-path
I am currently integrating the Zend Framework in my current project named VMM.
I decided to put the Zend Framework directory as a standalone project next to my VMM project in Eclipse.
I need to do some customization of the zend framework (For example I need to add Irradiance.php into Measure) and I would like to know where is the best place to put all my customizations.
I know that I need to follow the Zend Framework naming convention and the same directory structure.
So for example Irradiance.php contain the Mylib_Measure_Irradiance class.
I was thinking to put the Mylib folder into ZendFramework/library/Mylib next to the Zend folder.
Is it the regular way to extend and customize the Zend Framework?
If not, should I put the customizations inside my VMM project or as an other standalone project?
Thanks!
UPDATE
This question helped me but I still need some help...
I tend not to put my own library style files into the ZF folder mainly because when you come to upgrade ZF you'll have to copy them all over to the new ZF.
On my localhost I have something like this
my-project is the project I am working on and contains all the models, views, controllers,etc for that project
/htdocs/my-project/application
/htdocs/my-project/public
library is my own library files and mimics the ZF structure
/htdocs/library/Db/
/htdocs/library/Validate/
I then have my current ZF in /usr/lib/php/ZendFramework-x.xx.x this folder contains the latest ZF and can be changed easily without changing my projects or library code base.
Edit:
David's comments about 'pointers' reminded me, I always set up a sym link in /usr/lib/php/ called ZendLatest, this points to the latest copy of ZF, this means I don't have to keep changing my code or my php.ini.
There are many ressources out there:
http://www.slideshare.net/PHPBelgium/extending-zend-framework-presentation
http://cslai.coolsilon.com/2009/03/28/extending-zend-framework/
In ZF you create a project by running this command:
zf create project MyProjectName
But how does one load a project that already exists?
I don't see anything in the documentation that specifies a zf load project or zf set project or something like that.
Thanks.
This is not yet possible to my knowledge, but on the to-do list
See http://framework.zend.com/issues/browse/ZF-7940
You can simply create another zf project in a different directory and copy the xml file into the the folder where it's missing. in the xml file, everything is relative, so you don't have to worry about the newly dummy project's path and others.