Can I safely move the composer-generated Laravel project to a different directory?
3 answers
In general, projects built with Composer are self-contained and independent of its location in the file system (I'm not familiar with Laravel in ad hoc, but I have no reason to suspect any other behavior here). You can move / copy them without any problem.
As for your worries about plugins not loading after moving the directory: watch how Composer generates its autoloader classmaps (below is just a short excerpt):
<?php
// autoload_classmap.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'File_Iterator' => $vendorDir . '/phpunit/php-file-iterator/src/Iterator.php',
'File_Iterator_Facade' => $vendorDir . '/phpunit/php-file-iterator/src/Facade.php',
'File_Iterator_Factory' => $vendorDir . '/phpunit/php-file-iterator/src/Factory.php',
'PHPUnit_Exception' => $vendorDir . '/phpunit/phpunit/src/Exception.php',
// ...
As you can see, the autoloader is not attached to any pipes on the fixed filesystem, so even the classloader files that are automatically generated by Composer can be easily moved around the filesystem.
+6
source to share
I moved mine and it accidentally broke, unable to access any data via endpoints. Fix , in a new project;
- Make sure all files from the previous project folder are copied to the new folder. Especially in the file
.env
. - In the new folder, run
composer install
in terminal. - Then run
php artisan key:generate
to generate a new key in the.env
new folder file .
This worked for me.
+2
source to share