Laravel - How to change default folder for new projects

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 C:\Users\MyUser\MyApp directory.

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

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

    
asked by anonymous 20.02.2016 / 22:39

1 answer

2

The reason for this is that the Laravel installer creates the project in the directory where the 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 that directory.

Although there is no declared 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 project in the desired directory:

1st Mode:

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

cd Desktop\Sites

So if you navigate to the C:\Users\YourUser\Desktop\Sites directory and use the laravel new MyApp command, this location will create a directory with the name MyApp containing your Laravel installation, 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 you 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 prompt command here . By selecting this option you can create the project within this directory.

3rd Mode:

You can give the full path to the project and any 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 this case MyApp.

    
22.02.2016 / 09:33