I am working on a project in php Phalcon.
I am working with the Xampp server. The installation process that I followed is on this link:
http://docs.phalconphp.com/en/latest/reference/install.html
I am following the documentation on the website as guide and tutorial.
My problem is, every time I type "class MyClass extends \Phalcon\Mvc\Model"
it says undefined namespace "Mvc" and in other files it also gives error that Phalcon is an undefined namespace.
The installation seems okay.
Please help me out.
I think this is not really a problem with the installation of Phalcon.
I have recognized the same behaviour of my IDE because Phalcon is only loaded as an extension of PHP and not available as real PHP files which can be indexed by your IDE.
The easiest way to check if install was ok is to create a info.php in your project root.
<?php
phpinfo();
If you open this file in browser it should show a block with information about phalcon.
There is a script that creates stub files for you that can be integrated in you project.
https://github.com/phalcon/phalcon-devtools/blob/master/ide/gen-stubs.php
If these files are indexed by your IDE, the message of Undefined namespace should be gone.
If your code works. And IDE shows Mvc undefined namespace then you have to install Phalcon developer tool plugin for your IDE. the plugin is available for PHPStorm. Phalcon is a C extention and for this if you not install developer tool plugin then IDE will show undefined namespace.
Phalcon has different ways to use model like register model class, register namespace or register dir. If you create the model by command rather than manually write code you will get the proper base model class to extend. If still problem then there is problem with Phalcon installation.
Use --namespace="" for model:
phalcon create-model profiles --namespace="Application\Models"
For scaffold:
phalcon create-scaffold profiles --ns-models="Application\Models" --ns-controllers="Application\Controllers"
If you do not register the model namespace and register only model directory then edit the model file after creation and remove the namespace definition.
first check if php load phalcon module. for that in terminal type
php -r "echo phpinfo();" | grep 'phalcon'
if everything went write you should see line
phalcon => enabled
in windows grep wont work and you should look for that line yourself.
Related
How can I fix this alert in PhpStorm?
And also how to get autocompletion for Route and other Facades?
Check the Laracasts walkthrough
1) Go to: https://github.com/barryvdh/laravel-ide-helper
2) Click on the gist
Generated version for L5: https://gist.github.com/barryvdh/5227822
3) Click on "Raw" to get the current version (as of June 22, 2016 it is):
https://gist.githubusercontent.com/barryvdh/5227822/raw/4d4b0ca26055fa4753b38edeb94fad2396c497c0/_ide_helper.php
4) Make sure you're in your root directory (this is mine)
cd /var/www/html/project
5) Download the gist:
wget https://gist.githubusercontent.com/barryvdh/5227822/raw/4d4b0ca26055fa4753b38edeb94fad2396c497c0/_ide_helper.php
6) Add "_ide_helper.php" to the .gitignore file
sudo nano .gitignore
Add "_ide_helper.php" on a new line at the bottom
7) Download the .gitignore and _ide_helper.php files into PhpStorm
This is what my PhpStorm project directory looks like afterwards:
8) After the files are downloaded into PhpStorm, the "Undefined class" error will disappear and autocompletion will now work. Might need to restart it.
There is greate IDE support for Laravel shipped from Baryvdh:
https://github.com/barryvdh/laravel-ide-helper
after you install it you just call in the console:
php artisan ide-helper:generate
which generate alll facede shortcuts in _ide_helper.php file (which you have to exclude from git)
There is also something special for PhpStorm:
php artisan ide-helper:meta
which will give Laravel container context for example:
$foo = app(Foo::class);
PhpStorm will know that the $foo variable is type of Foo class.
I know this is an old thread, but it is still relevant. For me, I decided to add the following to my routes/web.php since I don't want to have to worry about regenerating meta data for the app.
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Auth;
Edit: The above does not add any overhead to PHP as the use simply acts as a reference for PHP.
I solved this problem simply by installing the Laravel idea plugin.
Use the following link:
https://laravel-idea.com/
You can install it on your phpstorm.
Its good feature is that you can use it for 30 days for free and pay the amount after satisfaction.
I am seeing namespace errors all over the place and I am not sure why.
For exampe I have:
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
and Configuration is in red and the error reads:
Undefined namespace Configuration less... (Ctrl+F1)
Referenced namespace is not found.
How do I fix this?
Since you say "Configuration is in red" I assume the problem you are experiencing is related to the IDE
If you are using PHPStorm there's a specific Symfony plugin that handle all the namespacing pretty much automatically, as long as your setup is standard.
By standard I mean a project dir containing the app/ src/ web/ ... dirs (if you're using the 2.x Symfony dir layout)
This link will tell you everything you need, in great detail
It may be your .idea folder which is corrupted. Close your project, delete the .idea folder and restart the IDE. It worked for me.
I'm developing an app in Laravel 5.1. And for some reason there's loads of default namespace paths that are red (using PHPStorm 10). They are marked as "undefined namespace"
For example, when I make a model with artisan it ends up with this:
use Illuminate\Database\Eloquent\Model;
class Form extends Model
{
//
}
And Eloquent is red. So I can't use the model.
Same goes in app/config/app.php
Where Illuminate\Support\Facades\
where Facades is red.
These are tons of namespace errors like this (under the Illuminate root ). Any idea with it might be? See below...
It's a problem of PHPSTORM.
For those who have this problem, I resolve it by :
- close phpstorm
- remove the project folder .idea
- create a new project with existing files.
It worked for me.
In PhpStorm :
Delete the .idea folder from your project,
File => Invalidate Caches / Restart,
Restart PhpStorm.
It worked for me.
Try this:
Open setting-> (setting path in image)
check "Synchronize IDE settings with composer.json"
When it happens to me, I place my cursor before use and press enter.
Sometimes it fixes that.
I'm attempting to build a test project with the Zend framework and using MAMP to run it on my local host.
The project creation works fine; I navigate to my htdocs directory and use zf create project my_zend to create the scaffold.
My error comes when I try to create a controller "students" by using the following command zf create controller students, however, once this command runs it outputs the following error:
Context by name servicesDirectory does not exist in the registry.
Where does this error come from?
I had the same problem, here is how I fixed it, check for the line:
<servicesDirectory enabled="false"/>
In the .zfproject.xml file and remove it.
You might get this error if you have another version of zend some where in the path. If you have one try deleting it and using the latest or the version you wish to. This worked for me in xamp on windows 7 hope it works for you
I decided instead of using the migration guide/shell for the upgrade from 1.3 to 2.0 of CakePHP to just go with a vanilla installation of it. For some reason, I'm getting this error:
Fatal error: Class 'Component' not found in /home/bob_cobb/public_html/mydomain.com/lib/Cake/Controller/Component/SessionComponent.php on line 32
When trying to access my website. I looked to see if SessionComponent.php even exists and it doesn't on my server, nor in the 2.0 repository. Do I need to create this file or something? (Edit: The file exists.)
its not about the sessioncomponent but the Component class itself:
App::uses('Component', 'Controller');
This declaration says where to find it. But cake doesnt seem to find it. so it is probably missing.
it should be in /Cake/Controller/
Actually, SessionComponent.php does exist, at least in the official 2.0.6 repository. Your download/upgrade was probably corrupted. Try adding the file to your server. If you're lucky, that's the only issue; more likely, though, you'll need to reupgrade.
I'm not sure where you're looking, but SessionComponent.php does actually exist in the 2.0.x repo:
https://github.com/cakephp/cakephp/blob/master/lib/Cake/Controller/Component/SessionComponent.php
You may want to re-download your whole /lib section if you're missing files.