After having installed the HTTP extension from PECL, I expected Zend Studio 6 to recognize the provided HTTP* classes and for code completion to be made available. This is not the case, however. How do I get Zend Studio to recognize classes provided by PHP extensions? Specifcally, I want to be able to use code competition on these classes.
I used the phpgenerator.php script from Michael Spector. It generates a php documentation folder with the loaded extensions on your pc. Afterwards the doc path can be added to the Eclipse (Zend Studio) include path. Code Completion works like a charm.
usage:
console: php phpgenerator.php $path_to_doc_output
http://dev.eclipse.org/viewcvs/viewvc.cgi/org.eclipse.pdt/plugins/org.eclipse.php.core/Resources/language/?root=Tools_Project
This script can be used for generating PHP model for PDT.
It builds PHP functions according to the loaded extensions in running PHP,
using complementary information gathered from PHP.net documentation
*
#author Michael Spector
In Eclipse, with which Zend Studio shares code, so it might help, is the "PHP Include Path".
"PHP Include Path" is in the project explorer.
There you can add the directory where the extensions are. Then Eclipse will scan it and you will be able to code-complete.
I did the same with PhpUnit2.
I'm not familiar with Eclipse, but if it works in the same way as Netbeans handles PHP extensions, you'll need to add the relevant stub PHP files to the IDE's search path.
You can add functions to Studio by putting PHP files with stub function descriptions into special directory. Find this directory in filesystem in a following way: write something like gmdate(), select the name and press F3. You will be taken to one of the prototype files. Note the directory where this file resides (shown on the top and if you hover over the tab). Now you need to create stubs for functions you are missing just like the one you're looking at. You can put them into any file, generally, but I suggest putting them into separate file - like geoip.php - and put this file into that directory. You may also want to do right-click/Show In/PHP Explorer and browse other prototype files if you need examples of how to do it right.
Zend ship language support for all the extensions in Zend Studio.
The most efficient way of adding support for language entities provided by unsupported extensions is definitely creating stubs (You can add this support yourself). The description "stub" files for all supported PHP entities can be found in this directory:
/.metadata/.plugins/org.eclipse.php.core/language
(this is also the location where you should put your stub files).
Related
I recently installed Zend Studio 9 and created a Zend Framework project. In the setup options it says that it includes the Zend Framework library and when a project is created, under all the project files in the php explorer it says it's being included.
While this is true, I notice that the 'library' folder is empty. When I try to run public/index.php in the browser, it doesn't display anything.
My question is how can you include the built in library so that my public/index.php file shows in the browser? I know you can download the zend library files and put them in the library folder, but that gives a ton of warnings, and I can't help but think there is an easier way when the library is supposedly built right in.
Adding ZF support to a project in Zend Studio makes the IDE aware of the classes and file structure of the library so you get code completion, method descriptions, and argument lists presented to you in the IDE but does not actually give you access to the library.
You will need to download the actual files when you want to run/deploy your project. You can put them in your library folder, but typically I put them in a more common location that I add to the PHP include path in php.ini. This is optional though. If you drop the Zend folder in your library folder, you technically wouldn't need to add ZF support to the project since the builder will become aware of all the ZF content by analyzing all of thy ose files.
On another note, try editing php.ini and setting display_errors to 1 so you don't get a blank page. There is an error but it is being hidden due to the display_errors setting.
I have a question about PHP projects in eclipse.
I have Aptana and PDT installed in my eclipse.
When I create PHP Project, I have something like this:
But if I add PHP nature to the project (org.eclipse.php.core.PHPNature) then I get following picture:
Is this normal at all? What are the benefits of this PHP nature?
This is absolutely normal and part of how PDT provides Code Assist in PHP projects.
Basically PHP Language Library contains what you can find in the PHP documentation. When you call a core function e.g. preg_replace() it will provide Code Assist, like autocompletion and showing you which arguments the function takes. It's just a bunch of Interfaces for core features, SPL containing phpdoc generated from the documentation.
The PHP Include Path resembles your include_path in PHP, in that you can refer to stuff outside your project, e.g. PEAR or a common folder containing shared PHP classes, which are then recognized by Eclipe's Code Assist.
is just a hierarchy view of your global namespace, similar to how you can unfold a php file and see its hierarchy directly from the explorer.
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
Was wondering when we right click on project folder in php explorer then there is an option "Php include path" it does not edit include_path property of php.ini . Hence even specifying include path using this option it does no different to project then whats its purpose of it??
Its is used to link two projects together within eclipse. If one project includes code from another project, eclipse is not aware of the connection and only evaluates the code with the project you are in. So if you try and use a function from another project for example, there would be no auto complete etc for that function.
By adding the second project to your include_path you are telling eclipse that you are using that project and all that projects classes, functions etc will be added to the auto complete and documentation prompt.
You are still required to connect the two by code.
The webserver (more accurate: The interpreter process created by the webserver) cannot know, that you even use an IDE to write your scripts, so its also impossible for it to know the project settings. If you execute it from within eclipse, it provides a custom php.ini, that contains the given include-path.
I am struggeling getting content/code assist to work for PHP libraries (other than Zend) in my Zend Framework project folder:
library
Doctrine
Zend (<-works with code assist...)
ZendX
Content assist remains blank when using this libraries...
Any suggestions?
Thanks, Udo
Content Assist is available for any compatible resources in the include path.
Right click your project folder. Then Include Path. Then Configure Include Path. A window will appear. Configure any needed resources.
Further Information in the Zend Studio Manual:
Adding Elements to a Project Include Path
Include Paths
Code Assist Concept
This may be helpful for some one, I am using eclipse kepler, and I did not find Include_path variable. If you have same probleme as me, right click on the project and select configure then add php support. This will add php include path to your properties option. Then chose php include path and in the libraries folder add zend library location.