What are the Differences Between "php artisan dump-autoload" and "composer dump-autoload"?

258,693

Solution 1

Laravel's Autoload is a bit different:

  1. It will in fact use Composer for some stuff

  2. It will call Composer with the optimize flag

  3. It will 'recompile' loads of files creating the huge bootstrap/compiled.php

  4. And also will find all of your Workbench packages and composer dump-autoload them, one by one.

Solution 2

php artisan dump-autoload was deprecated on Laravel 5, so you need to use composer dump-autoload

Solution 3

composer dump-autoload

PATH vendor/composer/autoload_classmap.php
  • Composer dump-autoload won’t download a thing.
  • It just regenerates the list of all classes that need to be included in the project (autoload_classmap.php).
  • Ideal for when you have a new class inside your project.
  • autoload_classmap.php also includes the providers in config/app.php

php artisan dump-autoload

  • It will call Composer with the optimize flag
  • It will 'recompile' loads of files creating the huge bootstrap/compiled.php
Share:
258,693

Related videos on Youtube

Naing Lin Aung
Author by

Naing Lin Aung

nothing speical

Updated on May 20, 2021

Comments

  • Naing Lin Aung
    Naing Lin Aung almost 3 years

    I am pretty new to Laravel 4 and Composer. While I do Laravel 4 tutorials, I couldn't understand the difference between those two commands; php artisan dump-autoload and composer dump-autoload What's the difference between them?

    • Jimmy Obonyo Abor
      Jimmy Obonyo Abor about 8 years
      just to point out though , php artisan dump-autoload is not included in L5
    • mchomvu
      mchomvu about 2 years
      I got this message after running dump-autoload in console Class App\Http\Middleware\AdminRedirectIfAuthenticated located in ./app/Http/Middleware/AdminRedirectifAuthenticated.php does not comply with psr-4 autoloading standard. Skipping.
  • woens
    woens almost 10 years
    But you still need to run composer dump-autoload as well as artisan dump-autoload in order to get all autoloads right. Example: After a migrate:make, you need a composer dump-autoload in order to do a migrate:rollback. artisan dump-autoload does not work here.
  • rajangupta
    rajangupta almost 5 years
    php artisan dump-autoload is deprecated on Laravel 5, so you need to use composer dump-autoload
  • Brad Ahrens
    Brad Ahrens over 4 years
    This is correct. For more information: laravel.com/docs/5.8/seeding#running-seeders
  • Čamo
    Čamo over 3 years
    Command "dump-autoload" is not defined. What it means?
  • totymedli
    totymedli over 3 years
    Did you really just copy-pasted the last points from Antonio's answer?