Skip to content

Instantly share code, notes, and snippets.

@jasperf
Last active April 29, 2017 05:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasperf/b84d74874227e0681126150d220b395b to your computer and use it in GitHub Desktop.
Save jasperf/b84d74874227e0681126150d220b395b to your computer and use it in GitHub Desktop.
Set up Laravel PHP from scratch using Valet or Homestead for local development. If you use Homestead skip Valet stuff and do Homestead stuff
#Composer dependency manager
#https://getcomposer.org/download/
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '669656bab3166a7aff8a7506b8cb2d1c292f042046c5a994c43155c0be6190fa0355160742ab2e1c88d40d5be660b410') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
#https://getcomposer.org/doc/00-intro.md#globally
mv composer.phar /usr/local/bin/composer
#http://stackoverflow.com/questions/25373188/laravel-installation-how-to-place-the-composer-vendor-bin-directory-in-your#25373254
echo 'export PATH="$PATH:$HOME/.composer/vendor/bin"' >> ~/.bashrc
source ~/.bashrc
#Valet Easy Local Server Setup OSX
#for Homestead or Windows skip
#https://laravel.com/docs/5.4/valet
#Homebrew needed
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew update
#add PHP 7.1 and MariaDB
brew install homebrew/php/php71
brew install mariadb --devel
#install valet
composer global require laravel/valet
valet install
#Create a new directory on your Mac by running something like mkdir ~/Sites.
#Next, cd ~/Sites and run
valet park
#Homestead Vagrant Box
#https://github.com/laravel/homestead
#https://laravel.com/docs/5.4/homestead
#must install VirtualBox 5.1, VMWare, or Parallels as well as Vagrant.
vagrant box add laravel/homestead
#better to run homestead in sepearate folder so you can run
cd proper-directory
# clone inside new homestead folder
git clone https://github.com/laravel/homestead.git homestead
cd homestead
bash init.sh
#Do not forget to edit Homestead.yaml to load the proper folder data,
#to add your sites and to add the database name
#folders:
# - map: ~/webdesign
# to: /home/vagrant/webdesign
#
#sites:
# - map: homestead.app
# to: /home/vagrant/webdesign/Laravel/public
# - map: site.dev
# to: /home/vagrant/webdesign/site.com/site-v2/public
#
#databases:
# - homestead
# - site
vagrant box add laravel/homestead
#choice 3 for virtualbox
#edit /etc/host to add domains
#Homestead
#192.168.10.10 homestead.app
#192.168.10.10 site.dev
# or with vagrant hostmaster and making it work for Homestead by adding:
#
#if Vagrant.has_plugin? 'vagrant-hostmanager'
# config.hostmanager.enabled = true
# config.hostmanager.manage_host = true
# config.hostmanager.manage_guest = true
# settings = YAML::load(File.read(homesteadYamlPath))
# config.hostmanager.aliases = settings['sites'].map { |item| item['map'] }
# puts "hostmanager aliases: " + config.hostmanager.aliases.join(' ')
# else
# fail_with_message "vagrant-hostmanager missing, please install the plugin with this command:\nvagrant plugin install vagrant-hostmanager"
# end
#
#to Vagrantfile
# see https://medium.com/@kernelfolla/a-quick-journey-through-laravel-homestead-e18afd7c264a
#Install Laravel
composer global require "laravel/installer"
# change to ~/valet or another directory for app development like ~/Code
cd ~/valet-directory
laravel new app
cd app
#create an eloquent model, controller and migration
php artisan make:model Post -mc
#before any migration create a database
# Sequel Pro works really well for this on OSX
#and edit .env using something like
#DB_CONNECTION=mysql
#DB_HOST=127.0.0.1
#DB_PORT=3306
#DB_DATABASE=blog
#DB_USERNAME=root
#DB_PASSWORD=
#for homestead it will be different
#DB_CONNECTION=mysql
#DB_HOST=127.0.0.1
#DB_PORT=3306
#DB_DATABASE=blog
#DB_USERNAME=homestead
#DB_PASSWORD=secret
php artisan migrate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment