In Laravel, what is meant by the term "clear compiled class" - laravel-4

I'm trying to use a service class in Laravel called ide-helper. It provides auto completion into PHPStorm. it is not functioning as expected. I have been advised that I should run php artisan clear-compiled.
what does the term "clear compiled" mean ?
https://github.com/barryvdh/laravel-ide-helper#automatic-phpdoc-generation-for-laravel-facades
Many thanks

Laravel uses an optimized class loader for better performance.
The command php artisan clear-compiled deletes the following 2 files:
bootstrap/compiled.php Created when you optimize classes.
app/storage/meta/services.json This file is created as Laravel tries to optimize the loading of the service providers your application uses.
For more Information on performance optimizing also see http://laravel-recipes.com/recipes/60/optimizing-the-framework-for-better-performance

Related

Why do I need to run php artisan optimize after adding a route

If I do not run php artisan optimize and I go to a new route in the browser I get Page not found
Everytime you push a new version of your project to production it is recommended to run php artisan route:cache.
On dev environment it is recommended to have no cache and ensure that by running php artisan route:clear.
When you do
php artisan route:cache
A file like bootstrap\cache\routes-v7.php gets created holding all your routes from routes\*.php which are contained in Route methods that weight some calculation cost on your server each time you send a request to figure what to do for the current route.
Quoting from bootstrap\cache\routes-v7.php comments:
This allows us to instantaneously load the entire route map into the router.
Important:
This cache file doesn't get auto updates and doesn't exist in a fresh project.
This cache takes precedence over routes\*.php files.
The bootstrap\cache folder is ignored by default by git.
Here is an extensive great article for more details https://voltagead.com/laravel-route-caching-for-improved-performance/
Note that the optimize command was removed from the framework then added back.

Command "october:migrate" is not defined

I must add table to existing octobercms project and added migration but it is not migrating. what may be problem? when I type php artisan october:migrate I faced with this problem
Command "october:migrate" is not defined.
Did you mean one of these?
october:down
october:env
october:fresh
october:install
october:mirror
october:passwd
october:up
october:update
october:util
php artisan october:up will only migrate the database
php artisan october:update will update the application files, plugins and migrate the database.
Check out this thread on the official forum
https://octobercms.com/forum/post/artisan-migrate
I had a similar issue: https://github.com/octobercms/october/issues/5589
It looks like the october:migrate would be available once you updated to the version 2.
It is a paid one.

Installing (Laravel) Dusk on Lumen

I am building a self-consuming Lumen API that has a single Lumen view (which serves the HTML to which the React app is appended).
I was able to install Dusk with
composer require --dev laravel/dusk
which seemed successful.
However, when I run
php artisan dusk:install
I get
There are no commands defined in the "dusk" namespace.
I know Lumen has a stripped-down php artisan. But, wondering if I can add the commands to the "dusk" namespace, or if anyone has successfully used Dusk with Lumen.
Thanks to Jared's answer,
I found I had to manually register Dusk's service provider before I could run php artisan dusk:install. The current Laravel documentation doesn't mention registering it, but it seems like it might have to be done for Lumen.
So all I had to do was add
if (app()->environment('local')) {
$app->register(Laravel\Dusk\DuskServiceProvider::class);
}
to /bootstrap/app.php below the Register Service Providers comment.
As Jared mentions, you don't want it to register in production environments so I stuck it in a conditional.
Once added, I was able to run php artisan dusk:install and got Dusk scaffolding installed successfully.
Be sure you have the .env file setup correctly.
The APP_ENV should be set to local or testing for dusk to work.
Also check if it's was correctly installed by checking the Register Service Providers in your bootstrap/app.php file. Dusk should be listed there.
If you are manually registering Dusk's service provider, you should never register it in your production environment, as doing so could lead to arbitrary users being able to authenticate with your application.

Getting strange errors installing a Laravel application

The first problem I'm running in to is that when installing I receive a mysql error stating that a table cannot be found. Of course it can't, I finished installing the dependencies much less run the migration. The error was being triggered by a Eloquent query in a view composer. After commenting out the entirety of my routes file Composer let me continue.
I proceed to uncomment out my route file - I get the error once again trying to run any artisan commands (can't migrate my database because I haven't migrated my database). Repeat the solution for step one and I've migrated my database.
Artisan serve is now serving me my layout file in the terminal and exiting. I'm at a bit of a loss to troubleshoot this. I assumed that it was possibly a plugin, trying to disable plugins one by one results in:
Script php artisan clear-compiled handling the pre-update-cmd event returned with an error
and being served up my layout file in the terminal.
It seems that the error is directly related to this function in my routes file:
View::composer('layouts.main', function($view) {
$things = Thing::where('stuff', 1)->orderBy('stuff')->get();
$view->with(compact('things'));
});
This isn't a new introduction to the application however so the underlying cause is coming from somewhere else.
As i said in the comment, if you are finding database errors in production server but not in local, then
check database credentials. if its ok then....
check the different configs in the environment.
using profilers(any) will let you know what environment you are in.

Laravel Generate not working

I am running Sublime Test 2 in Windows 7 64-bit. I have installed (and re-installed many times) Laravel Generator and Laravel 4 Artisan. I have updated composer and all dependencies. But I cannot get it to work properly. If I press ctrl-shift-P and type 'laravel' I get a list of 11 Artisan options, then a list of 17 Generate options, 6 of which appear to be duplications, and then another list of 20 Artisan options. The first lot of Artisan options give WindowsError: [Error 2] The system cannot find the file specified, the Generate options give [InvalidArgumentException] There are no commands defined in the "generate" namespace.
The second batch of Artisan options do appear to work eg Laravel Artisan: Controller: Make gives a command line and if I type 'test' it creates a restful controller called test.php.
However, the more comprehensive resource generation remains unavailable to me.
Can anyone shed any light?
If you are using the way/generators package, you need to make sure to include the service provider ('Way\Generators\GeneratorsServiceProvider') in your config.app file.
First make sure you install this plugin first: https://github.com/laravelbook/laravel4-sublimetext-helper
And then you might want to do what is referred here:
http://net.tutsplus.com/tutorials/tools-and-tips/pro-workflow-in-laravel-and-sublime-text/#comment-925470112
There are other Windows users that had difficulties with this, but seem to have resolved them.

Resources