Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vincent15000's avatar

What's the best way to create my own laravel script to install my laravel app ?

Hello,

To install a new Laravel application, I can use the laravel command like this : laravel new my_super_app.

What is the best way to create my own command, for example my_super_app new ....

The aim is to be able to install all what is needed with only one unique command, that means Laravel, VueJS, ... all dependancies, the database, ... and then I just have to connect to the app and all works fine.

I have seen the code for laravel command.

Thanks for your help.

V

0 likes
7 replies
Snapey's avatar

bash script or bat file depending on your OS

For instance, in my .zshrc file

breeze() {
   laravel new 
   cd 
   cp .env.example .env
   composer require --dev laravel/breeze
   php artisan breeze:install
   composer require --dev barryvdh/laravel-debugbar
   git init
   git add .
   git commit -m Initial
   herd link 
   php artisan key:generate
   npm install && npm run dev
   read -p "Press enter to continue"
   code .

}

but I've not used this for a while so would need to adjust it

1 like
vincent15000's avatar

@Snapey Linux ... the distribution is not yet chosen, but it has to be installed on a Rasberry Pi in the future.

vincent15000's avatar

@Snapey Effectively a simple bash script is better, so why the laravel command is so complex ?

martinbean's avatar

@vincent15000 There are many ways to skin a cat. Just pick a method that works for you and go with it, instead of worrying about how “simple” or “complex” other solutions are.

If a simple solution solves your need, then roll with it.

1 like
Tray2's avatar
Tray2
Best Answer
Level 73

If you are running on Mac/Linux then you can use a bash script. I made one that I used for a while until reinstalling my computer. You can use that as a starting point. Haven't invested any time to make it work on linux though.

https://github.com/Tray2/Laravel-scripts

1 like
LaryAI's avatar
Level 58

To create your own command to install a Laravel application with all the necessary dependencies and configurations, you can create a custom shell script or a PHP script that wraps around the Laravel installer and additional setup steps. Here's a step-by-step guide on how to create a shell script for this purpose:

  1. Create the Shell Script: Create a new file for your script, for example, install_my_super_app.sh.

  2. Make the Script Executable: Change the permissions of the script to make it executable:

chmod +x install_my_super_app.sh
  1. Write the Script: Open the script file in a text editor and start scripting the installation process. Here's an example of what the script might look like:
#!/bin/bash

# Define the name of the application
APP_NAME="my_super_app"

# Check if an argument is provided
if [ -z "" ]; then
  echo "Usage: 
./install_my_super_app.sh my_super_app_directory
<directory>" exit 1 fi # Create a new Laravel application laravel new "" # Change to the application directory cd "" || exit # Install Vue.js dependencies npm install vue@next vue-loader@next # Additional setup steps (e.g., database migrations) php artisan migrate # Install other PHP dependencies via Composer composer require example/package # Install other npm dependencies npm install # Compile assets npm run dev # Perform any other setup steps (e.g., seeding the database) php artisan db:seed # Success message echo "Application $APP_NAME has been installed successfully."
  1. Run the Script: You can now run the script by providing the directory name where you want to install your application:
alias my_super_app_new='/path/to/install_my_super_app.sh'
  1. Create an Alias (Optional): If you want to be able to run the command from anywhere, you can create an alias in your .bashrc, .zshrc, or equivalent shell configuration file:
LARACASTS_SNIPPET_PLACEHOLDER

After adding the alias, you may need to reload your shell configuration with source ~/.bashrc (or the appropriate file for your shell).

  1. Customize the Script: You can customize the script to include any additional steps that are specific to your application setup, such as configuring environment variables, setting up a specific database, or installing additional Laravel packages.

Remember that this script assumes you have laravel, npm, composer, and php installed globally on your system. If not, you'll need to adjust the script to use the correct paths for these tools.

By following these steps, you can create a custom command to install your Laravel application with all the necessary components in one go.

Please or to participate in this conversation.