phpstorm configuration for laravel, phalcon or codeigniter? - php

How do I configure PHPStorm autocomplete to framework codeignitir 3 and others, for example to call methods or function with ctrl+space?

This shouldn't be necessary for frameworks like Laravel or CodeIgniter, since their code should already be included in your PhpStorm project (and thus accessible to the IDE to facilitate code navigation/auto-completion/etc.).
However, since Phalcon is a PHP extension, you'll need to download its plaintext source files and include them as an external library in your PhpStorm project. To do this, clone the https://github.com/phalcon/phalcon-devtools.git repository into a folder outside of your main project folder. Let's call that folder "phalcon-devtools". Then from within your IDE: Preferences > Languages & Frameworks > PHP > Include Path > Add new > Specify other and choose the proper subfolder corresponding to the version of Phalcon you're using. (For example, phalcon-devtools/ide/2.0.5).

Related

How to make Eclipse with PDT work with registered Joomla namespace aliases?

What I'm trying to do is to start working under a Joomla! project in the Eclipse PHP IDE with PHP Development Tools installed. I use Eclipse Oxygen for PHP Development and work with a Joomla 3.8.2 project.
After creating project and importing the code, I get validation errors about not being able to resolve some class to a type. For example:
$par = JComponentHelper::getParams('com_somecomponent');
This gives me a validation error:
JComponentHelper cannot be resolved to a type.
I assume this is due to the fact that JComponentHelper is a registered Joomla! alias and the real name is \Joomla\CMS\Component\ComponentHelper. How can I provide Eclipse with this information to be able to correctly resolve the namespace?
The Joomla project has been gradually migrating the framework's classes out of the global namespace but provides aliases to ease the transition for older projects and extensions. As we know, Eclipse cannot infer information about these aliases because Joomla generates them dynamically using PHP's class_alias() function.
Since version 3.8.0, Joomla provides a stub generator that analyzes the classes in the framework to create a file that IDEs can easily load the missing information from:
As Joomla transitions its core classes from residing in the global PHP namespace to using namespaced PHP classes, it will be a common occurrence for developers to work in an environment where their code is still using the old class names which may not exist in newer Joomla releases except for in PHP's autoloader as a class alias. This script therefore allows developers to generate a mapping file they can use in their local environment which will create "real" classes for the aliased class names and allow things like IDE auto completion to work normally.
We can generate this file by running the stubGenerator.php utility located in the build/ directory from a command prompt or terminal:
php build/stubGenerator.php
...which creates a stubs.php file in the project's root directory. Then, Eclipse should display the Content Assist information for the aliases. This file also works for other IDEs like NetBeans and PHPStorm. A minor caveat:
Note that this file will raise some IDE errors as it will generate stub classes extending a final class (something not allowed in PHP). Therefore it is suggested that inspections on this file are disabled.
Unfortunately, we can't exclude a single file from PDT's PHP validation, but we can delete the errors from the "Problems" window if they appear which should suppress them until we regenerate the stubs file.
While this solves the problem in Eclipse, we need to consider that upcoming Joomla releases deprecate many of these aliases for removal, so we want to avoid referencing these when possible as Joomla moves towards Composer and the PSR-4 namespacing convention.
Instead of using the alias directly:
$par = JComponentHelper::getParams('com_somecomponent');
...consider importing the class:
use Joomla\CMS\Component\ComponentHelper;
...
$par = ComponentHelper::getParams('com_somecomponent');

Best practice for Laravel 4 + Zurb Foundation 5?

TL;DR: what is the best way to arrange files, package managers and build tools for Laravel 4 + Zurb Foundation 5 combo (with Compass) as one consistent repository with clean public (static) section?
I wanted to start a fresh project, based on latest Laravel on the backend side and using Foundation for the frontend. I am new to both of these and apparently I missed some of the tooling that was developed meanwhile when I wasn't doing PHP for some time.
My confusion:
Laravel uses Composer for installation and dependency/module management. (Ok, I'm new to Composer)
Foundation is available as a Composer module (but then what?), but generally also as a CLI tool that creates a new project and uses bower for module/dependency management. But then I have two repositories.
Is it required for me to expose all my .scss files, or maybe even put the whole Foundation project into laravel's public dir to make all work?
How do people usually approach using these frameworks together? They shouldn't interfere, but they still have totally different tooling.
Where do I put my foundation files? Keep it as composer module or inside public? How to refer to them? How to have one build everything command?
I have the same issue as using Bootstrap SCSS version for Admin & Foundation SCSS for the frontend. I noticed also that both css frameworks come as composer packages however the issue you have with this approach is that you generally use other Javascript files in a development that will be merged also so using the composer versions just adds to the confusion.
The best solution i found was using either gulp or grunt with bower at the top level of your Laravel build. Rather that go through the configuration for you there is a good article at http://blog.elenakolevska.com/using-grunt-with-laravel-and-bootstrap/ that goes over a bootstrap integration but this can be tweaked for Foundation. This solution is good as grunt has many of the other popular javascript libraries that you may use in your project also..
Alternatively you could use an application like codekit and create a compass project to manage the merging & compiling of your assets into the public folder. As a side note if using git again your would need to exclude additional folders from your project.
If you think of your SCSS framework files as development assets there is no real need for them to be in the project as you only really need one version of Foundation on your development machine.
Your custom SCSS changes can be added to your Laravel project as modules ie a navigation module, via a private composer repo for the project or just added to the Compass project at development time. Your public folder should only be referencing the final merged style.css & java.js files for example. Any images from the framework can then just be copied over to the public folder ie icons etc.. Hope that helps..
Personally I have a "static" directory which houses static files. That is where I use SASS watchers, grunt tasks and basically the entire front-end workflow. The results of that front-end build process gets added to a "production" Laravel public directory after getting built, etc.
A pro of this is that everything (static assets and laravel application) is separate.
A con is that updating Laravel views with any updates in HTML templates you may build in the static directory. If you update the templates, you may also need to update the view files, which becomes more tedious as you add more templating logic around the HTML in the views.
Just one suggestion.

Zend Studio 9 include built in Zend Framework Library

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.

Inside Eclipse PDT whats the purpose of "PHP include path" in project properties?

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.

Code completion for PHP extensions in Zend Studio?

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).

Categories