Skip to content

Instantly share code, notes, and snippets.

@sdbruder
Last active May 10, 2017 08:59
Show Gist options
  • Select an option

  • Save sdbruder/21716d63ba5de9fdc85fddb6fd7c68d0 to your computer and use it in GitHub Desktop.

Select an option

Save sdbruder/21716d63ba5de9fdc85fddb6fd7c68d0 to your computer and use it in GitHub Desktop.

Revisions

  1. sdbruder revised this gist May 10, 2017. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions newlaravel.sh
    Original file line number Diff line number Diff line change
    @@ -20,6 +20,7 @@
    # - ~/src/$repo, http://$repo.app, DB $repo, all will be named accordingly;
    # - your homestead is in 192.168.10.10. if not, please change it below;
    # - you have /vagrant/scripts/serve-laravel.sh in working conditions;
    # - your vagrant user in homestead has a working .my.cnf configured;
    # - all your projects will reside on ~/src/$project on your home;
    # - add #LARAVEL_LIST_START somewhere in your /etc/hosts file;
    #
  2. sdbruder revised this gist May 10, 2017. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion newlaravel.sh
    Original file line number Diff line number Diff line change
    @@ -33,7 +33,8 @@ sudo sed -i 'bak' '/#LARAVEL_LIST_START/a\
    ' /etc/hosts

    # setup nginx
    ssh homestead "sudo bash /vagrant/scripts/serve-laravel.sh $repo.app /home/vagrant/src/$repo/public ; sudo service nginx restart"
    ssh homestead "sudo bash /vagrant/scripts/serve-laravel.sh $repo.app /home/vagrant/src/$repo/public "
    ssh homestead "sudo service nginx restart"

    # create database
    ssh homestead 'echo "create database '"$repo"';" | mysql'
  3. sdbruder revised this gist May 10, 2017. 1 changed file with 10 additions and 6 deletions.
    16 changes: 10 additions & 6 deletions newlaravel.sh
    Original file line number Diff line number Diff line change
    @@ -1,23 +1,27 @@
    #!/bin/bash

    ###
    #
    # newLaravelProject
    #
    # from an idea to a working freshly installed laravel in 20-ish seconds
    # with a composer create-project with prestissimo.
    # from an idea to a working freshly installed laravel in 26 seconds using
    # composer create-project with prestissimo.
    #
    # Sergio Bruder <[email protected]>
    #
    ###

    ###
    #
    # Assumptions:
    #
    # - all your projects will reside on ~/src/$project on your home
    # - your homestead environment will be callable as ssh homestead in your host;
    # - homestead points to your homestead in your host and points to 127.0.0.1
    # inside your homestead;
    # - you have /vagrant/scripts/serve-laravel.sh in working conditions;
    # - homestead points to your VM in your host and to 127.0.0.1 inside the VM;
    # - ~/src/$repo, http://$repo.app, DB $repo, all will be named accordingly;
    # - your homestead is in 192.168.10.10. if not, please change it below;
    # - you have /vagrant/scripts/serve-laravel.sh in working conditions;
    # - all your projects will reside on ~/src/$project on your home;
    # - add #LARAVEL_LIST_START somewhere in your /etc/hosts file;
    #
    ###

  4. sdbruder created this gist May 10, 2017.
    58 changes: 58 additions & 0 deletions newlaravel.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,58 @@
    #!/bin/bash

    ###
    # newLaravelProject
    #
    # from an idea to a working freshly installed laravel in 20-ish seconds
    # with a composer create-project with prestissimo.
    #
    ###

    ###
    #
    # Assumptions:
    #
    # - all your projects will reside on ~/src/$project on your home
    # - your homestead environment will be callable as ssh homestead in your host;
    # - homestead points to your homestead in your host and points to 127.0.0.1
    # inside your homestead;
    # - you have /vagrant/scripts/serve-laravel.sh in working conditions;
    # - ~/src/$repo, http://$repo.app, DB $repo, all will be named accordingly;
    #
    ###

    repo=$1

    # change /etc/hosts
    sudo sed -i 'bak' '/#LARAVEL_LIST_START/a\
    192.168.10.10 '"$repo"'.app
    ' /etc/hosts

    # setup nginx
    ssh homestead "sudo bash /vagrant/scripts/serve-laravel.sh $repo.app /home/vagrant/src/$repo/public ; sudo service nginx restart"

    # create database
    ssh homestead 'echo "create database '"$repo"';" | mysql'

    # composer install the laravel project
    cd ~/src
    composer create-project --prefer-dist laravel/laravel $repo

    # change .env to point to mysql in homestead
    cd ~/src/$repo
    sed -i 'bak' "s/DB_HOST=.*/DB_HOST=homestead/g" .env
    sed -i 'bak' "s/DB_DATABASE=.*/DB_DATABASE=$repo/g" .env

    # initial migrations
    php artisan migrate

    # initial commit
    cd ~/src/$repo
    git init .
    git add -A .
    git commit -m 'initial commit'

    # open url in the browser
    open "http://$repo.app"

    echo "$repo project started, happy Laraveling."