Skip to content

Instantly share code, notes, and snippets.

@MichalGallovic
Last active January 14, 2016 20:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MichalGallovic/f9e8bf501c8175ee828d to your computer and use it in GitHub Desktop.
Save MichalGallovic/f9e8bf501c8175ee828d to your computer and use it in GitHub Desktop.
Laravel 5.x - refresh compiled classmap
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
/*
* Add this to $commands array
* in App\Console\Kernel
*
* http://stackoverflow.com/questions/30819934/laravel-migrations-class-not-found
*/
class RefreshCompiledClassmap extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'migrate:compiled:refresh';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Refresh compiled classmap';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
// Clears all compiled files
$this->call('clear-compiled');
// Updates autoload_psr4.php, Almost empties autoload_classmap.php
shell_exec("composer dump-autoload");
// Updates autoload_classmap.php
$this->call('optimize');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment