Is NetBeans not accepting _ide_helper from Laravel? - laravel-5

Using NetBeans 8.2 with Laravel, I'm setting the _ide_helper.php to my project as described in his link https://github.com/barryvdh/laravel-ide-helper,
it was set on terminal the command
composer require barryvdh/laravel-ide-helper
then after, it was added into config/app.php the line
Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class,
and for last, the command on the project folder
php artisan ide-helper:generate
but nothing has changed apparently. No auto complete, no references. Here are some images comparing what is expected and what is happening.
Expected
Happening
Plus, NetBeans is marking an error inside the ide_helper file which confuses the syntax by the name of the function ('if'). I'll put an image of the part showing the error
Error_NetBeans_ide_helper
I've rebooted NetBeans, tried downloading and setting directly the file, but no lucky. Is the function 'if' causing the problem? Or is NetBeans not accepting the _ide_helper?

Related

View [layouts.app] not found in laravel

I have created an application in laravel using appzcoder crud-generator plug-in. i have done everything accordingly but i am getting the above mentioned error. I have a folder named layouts in views folder and this folder has app.stub in it. but when i run the project it gives the following error
View [layouts.app] not found. (View:C:\wamp64\www\myProject\resources\views\admin\items\index.blade.php)
make sure you have run below code if not run it will create layout.app path
or manually create view/layout/app.php
php artisan vendor:publish --provider="Appzcoder\CrudGenerator\CrudGeneratorServiceProvider"

Undefined class Route (Laravel in PhpStorm)

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.

Laravel 5.1 remove controller

I have simple question on Laravel 5.1. I have created a controller using php artisan command:
php artisan make:controller PageSettings
However it was mistake, because I really wanted to create this controller in Admin folder like this:
php artisan make:controller Admin/PageSettings
Now I want to get rid of my old PageSettings controller. Is it ok just to delete my old PageSettings.php manualy? Or there is something more what needs to be done?
If you only created it and found that you did it wrong, you can manually remove the file and that's it. However when you already added routes to this controller in routes.php you should remove them from routes.php file or alter the file to reflect your new controller.
It is OK to manually delete controller. Just check routes.php if you have some route to that controller and delete it also.
I had an issue with just deleting the file. I tried running my PHPUnit test suite and got an error that looked like this:
Warning: include(): Failed opening '/user/home/me/some/file.php' for inclusion (include_path='.:') in /usr/home/me/some/vendor/composer/ClassLoader.php on line 444
I had to run composer update then composer dump-autoload. After that, everything worked just fine.
Yeah, you can delete manually without tension.
I will suggest you for avoiding more mistakes, you "phpStrom" software, from using this, if you delete manually any file from by click right of mouse->Refactor->safe delete then before deleting they will give all places which were using your file. by clicking "do refactor" you can delete it.

php artisan optimize returns (Invalid filename provided.)

I was trying to publish my new laravel project using Forge+DigitalOcean but I get the error message (We were unable to install a project on your server) due to php artisan optimize command returning Invalid filename provided. error.
So I modified my .env file and set APP_DEBUG to false and tried to run the command locally. I got the following error:
php artisan optimize -v
Generating optimized class loader Compiling common classes
[RuntimeException] Invalid filename provided.
Exception trace: () at /home/bubut/Code/TalalAttendance/vendor/classpreloader/classpreloader/src/ClassPreloader.php:105
ClassPreloader\ClassPreloader->getCode() at
/home/bubut/Code/TalalAttendance/vendor/laravel/framework/src/Illuminate/Foundation/Console/OptimizeCommand.php:89
Illuminate\Foundation\Console\OptimizeCommand->compileClasses() at
/home/bubut/Code/TalalAttendance/vendor/laravel/framework/src/Illuminate/Foundation/Console/OptimizeCommand.php:70
Illuminate\Foundation\Console\OptimizeCommand->fire() at n/a:n/a
call_user_func_array() at
/home/bubut/Code/TalalAttendance/bootstrap/cache/compiled.php:1138
Illuminate\Container\Container->call() at
/home/bubut/Code/TalalAttendance/vendor/laravel/framework/src/Illuminate/Console/Command.php:150
Illuminate\Console\Command->execute() at
/home/bubut/Code/TalalAttendance/vendor/symfony/console/Command/Command.php:258
Symfony\Component\Console\Command\Command->run() at
/home/bubut/Code/TalalAttendance/vendor/laravel/framework/src/Illuminate/Console/Command.php:136
Illuminate\Console\Command->run() at
/home/bubut/Code/TalalAttendance/vendor/symfony/console/Application.php:827
Symfony\Component\Console\Application->doRunCommand() at
/home/bubut/Code/TalalAttendance/vendor/symfony/console/Application.php:191
Symfony\Component\Console\Application->doRun() at
/home/bubut/Code/TalalAttendance/vendor/symfony/console/Application.php:122
Symfony\Component\Console\Application->run() at
/home/bubut/Code/TalalAttendance/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:100
Illuminate\Foundation\Console\Kernel->handle() at
/home/bubut/Code/TalalAttendance/artisan:36
Laravel allows you to specify additional files to be compiled -- generally files that are used on every request in the application.
The file list is specified in /config/compile.php in the files array. If you have specified a file there but it does not exist (or the location is wrong) then artisan will throw that error when trying to compile it.
Same thing happened to me and removing the non-existent file from the list fixed my problem.
Same issue toady, and after debugging in Illuminate\Foundation\Console\OptimizeCommand, I found that some symfony components missing in vendor folder, even with composer install/update command for some reason.
Remove contents under vendor folder, then do composer update to see if missing components back. Or git clone whole project and composer update. Note that composer install will check composer.lock, if it existing and components missing there, issue triggered.
Note: For additional information
If your files are in a folder inside app folder, this is how you should list them.
'files' => [
'app/your_folder_name/file_a.php',
'app/your_folder_name/file_b.php',
'app/your_folder_name/file_c.php',
]
Hope this helps anyone who one to compile their custom functions.

Artisan packages error

I'm having some trouble with artisan/packages.. I've added a package to my composer file and ran composer update and an error was returned:
PHP Warning: require(/home/xxx/public_html/bootstrap/autoload.php): failed to open stream: No such file or directory in /home/xxx/public_html/artisan on line 16
I can see that require path is incorrect, my structure is like so:
/home/xxx/bootstrap
/home/xxx/app
/home/xxx/vendor
/home/xxx/public_html
I hadn't changed any of the paths and everything seemed to work out of the box with this structure, basically removing the public folder and pushing everything up a directory.
I've opened up Artisan tried a couple of paths that kept failing so i've changed them to absolute:
require '/home/xxx/bootstrap/autoload.php';
It seemed to work from here on, but at the end of the process got another error:
Writing lock file
Generating autoload files
[RuntimeException]
Could not scan for classes inside "app/commands" which does not appear to be a file n or a folder
Rather than continue to mess it up i thought now would be a good time to clear it up, any ideas how to fix this?
Make sure you are using php 5.3 or higher.
Run php -v
Try creating an empty "app/commands" folder, fixed the issue for me!

Resources