Search code examples
gitsetup-projectprojects-and-solutions

Best practice to automatically initialize project (git + composer + bower etc.)


I have private git repository with 2 git submodule (Backend - Laravel API REST & Fronted - AngularJS).

Once the developer clones the project, he must run a setup process to initialize this project.

For example:

git submodule init
git submodule update
cd backend
composer update
mv .env.example .env
php artisan migrate --seed
cd ../frontend 
bower install
etc ...
  • What is the best practice to run these commands automatically?
  • What is the best practice to simply tell to developer how to initialize project manually
    (maybe some readme file inside git repository)?

Solution

  • Sounds like you need a script that will do this work for you.

    Write the script, place it in your root folder of the project and tell user to run it. Using script will make your life easier if you modify the script and its content.
    You simply update the script skipping the need to update your doc unless you have to.

    If you use git (any OS) you can write bash/sh file bu simply copying the content in your question to the file and pushing it to git. Just make sure you set the execute permissions on the file so your users will be able to execute it.

    init_project.sh

    #!/bin/sh
    
    git submodule init
    git submodule update
    cd backend
    composer update
    mv .env.example .env
    php artisan migrate --seed
    cd ../frontend 
    bower install