Laravel - How to Change Default Folder for New Projects

Asked

Viewed 563 times

2

New projects created using the Laravel installer go to C:\Users\MyUser\.

For example if I use the command laravel new MyApp Laravel will be installed inside the directory C:\Users\MyUser\MyApp.

How do I change this path to another, for example:C:\Users\MyUser\Desktop\Sites?

So the command laravel new MyApp will install Laravel in C:\Users\MyUser\Desktop\Sites\MyApp.

  • Basically, as stated in the answer below, Laravel will create the project in the current directory + app name as folder. Just browse with the console and done, changed the folder :)

1 answer

2


The reason for this is that the Laravel installer creates the project in the directory at which command prompt or terminal is running and by default when you start the command prompt it will open in the path C:\Users\YourUser, soon the project will be created in this directory.

Although there is no stated or simple way to change the default path for creating Laravel projects this is not a problem as there are several ways to start a projects in the desired directory:

1st Mode:

Simply open the command prompt and navigate to the desired directory using the command cd. Example:

cd Desktop\Sites

So if you navigate to the directory C:\Users\YourUser\Desktop\Sites and use the command laravel new MyApp is at this location that will be created a directory with the name Myapp containing your installation of Laravel, ie you will have C:\Users\YourUser\Desktop\Sites\MyApp.

2nd Mode:

Open the prompt in the desired directory. Windows allows you to navigate through your file manager to the desired folder and open a command prompt there.

The way to do it will vary, but in Windows 7 for example, you right click + shift inside the directory and in the context menu you will have the option Open command prompt here. By selecting this option you can create the project inside this directory.

3rd Mode:

You can give the full path to the project and the directory that does not exist will be created by the Laravel installer itself. Example:

laravel new Desktop\Sites\MyApp

Directories that do not exist will be created and Laravel will be installed in the last directory, in case Myapp.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.