Installing Laravel in the Current Directory with 'laravel new' Seems Impossible [Alternative Solutions Included]
Thank you for your continued support.
This article contains advertisements that help fund our operations.
I explored alternative ways to install Laravel in the current directory since it seems impossible with the `laravel new` command.
Introduction
When creating a new Laravel project, you might want to set up a directory structure, for example, with Docker:
ProjectName
├── docker/
├── src/
└── docker-compose.ymlIn such cases, you might want to install the Laravel project inside the src directory. It would be convenient if you could install it directly in the current directory.
It's Probably Not Possible with laravel new
Methods I Tried
Without Specifying a Project Name
laravel newWhen prompted to enter a project name, inputting:
.results in:
Application already exists.
Using .
laravel new .Results in the following error:
Application already exists!
Using --force
laravel new --forceWhen prompted to enter a project name, it results in:
Cannot use --force option when using current directory for installation!
It Seems Impossible
This issue has also been discussed on Laracasts without a clear resolution for using laravel new:
Laracasts - Install Laravel to an existing folder
Alternative Solutions
Here are two alternative methods:
- Use Composer to install Laravel.
- Install Laravel in a temporary directory and move it.
Using Composer
composer create-project laravel/laravel:^11.0 .This command installs a Laravel project in the current directory, but it does not offer the starter kit selection provided by laravel new.
┌ Would you like to install a starter kit? ────────────────────┐
│ › ● No starter kit │
│ ○ Laravel Breeze │
│ ○ Laravel JetstreamHowever, you can manually install a starter kit afterward, and the rest of the workflow remains the same.
Breeze
composer require laravel/breeze --dev
php artisan breeze:installJetstream
composer require laravel/jetstream
php artisan jetstream:installLaravel Jetstream - Installation
Installing in a Temporary Directory and Moving Files
While not ideal, you can install Laravel in a temporary directory:
laravel new srcThis will result in the following structure:
ProjectName
├── docker/
├── src/src/ [files and folders installed here]
└── docker-compose.ymlYou can then move all files and folders from the nested src/src/ directory to the desired src/ directory.
Conclusion
I hope this helps someone looking for solutions to this issue!





