A place for me to brain-dump my process for creating a LAMP stack for Laravel with Foundation (sass) on a Vagrant machine. All steps (excepting those run in the VM) are run on my Mid 2009 Macbook Pro running (10.11.2).
So, you want to utilize this repo to help you get started even quicker with Laravel and Foundation? Great--follow the below steps to get started!
- Clone the repository
git clone https://github.com/MuffinTheMan/sbd-laravel.git- If you are planning on working on this project (i.e. not using this to build a new site), discontinue this "How to Use" guide; otherwise, continue
- Rename the repository to something that makes sense for your site
mv sbd-laravel my-site - Stop tracking the
sbd-laravelrepo withcd sbd-laravel && rm -rf .git - If you want to use git, run
git init(orgit-flow initif you're a git-flow person) - Ensure you have Composer and Node installed
- In the
laravel-projectdirectory runcomposer install(orphp composer.phar install) andnpm install- Note: you could rename the
laravel-projectdirectory as well, just be aware that you would also have to updatesetup.sh,laravel-project.confandVagrantfileto make sure everything matches
- Note: you could rename the
- Back in the main directory, you're now ready to use this project to setup your environment, run
vagrant upto get the VM going - Once complete,
vagrant ssh, thencd /setup && ./setup.sh. This will take a little while, but once it's done, you'll have a LAMP stack and a working Laravel site that can be viewed atlocalhost:8080
- Sass files are found under
resources/assets/sass - Current setup will only compile
app.scss--if you wish, you can create other sass files and import them intoapp.scss(such as_import_me.scsswithimport 'import_me' - Run
gulp(inlaravel-project) to compile sass - Run
gulp watchto keep gulp watching your sass files to compile as you update them - Use your compiled css file like so
<link rel="stylesheet" href="{{ elixir("css/app.css") }}"> - Store images under
public/images/
Here is the process--brain-dumped. This is for troubleshooting, etc. Follow the "How to Use" guide for, well, how to use it :)
- Initialize the Vagrant box with
vagrant init debian/jessie64 - Edit Vagrantfile
- Uncomment
config.vm.network "forwarded_port", guest: 80, host: 8080 - Add
config.vm.synced_folder "laravel-project", "/var/www/laravel-project", type: "nfs"andconfig.vm.synced_folder "setup", "/setup", type: "nfs"(on separate lines) after# config.vm.synced_folder "../data", "/vagrant_data"--ensure the path matches the actual location ofsetupandlaravel-projecton your machine- If you get an error such as
The host path of the shared folder is missing: setup, you need to ensure the foldersetuphas been created where you think it should be on your (host) machine
- If you get an error such as
- Uncomment
# config.vm.network "private_network", ip: "192.168.33.10"--this is needed for"nfs"to work above
- Uncomment
- Run
vagrant up- If you run into issues such as
mount.nfs: access denied by server while mounting 192.168.33.1:/path/to/setup-dump/setup, try running the following (on the host machine):sudo nfsd checkexportsIf there are errors, try editing/etc/exportsand deleting everything within, thenvagrant destroy -f; vagrant upshould do the trick!
- If you run into issues such as
- Create
setup/setup.shandchmod a+xit--this script will be run on the VM and begin withsudo apt-get update - Install Composer globally
curl -sS https://getcomposer.org/installer | php; mv composer.phar /usr/local/bin/composer - Install laravel with
composer global require "laravel/installer" - Add
~/.composer/vendor/bintoPATH- This may be done by adding (or updating)
~/.profileand then sourcing it. ~/.profile(see sample.profileinmiscfolder)
- This may be done by adding (or updating)
- Create your project with
laravel new laravel-project(note that this becomes thelaravel-projectthat is shared with the VM--if you had already created this empty folder, just delete it and run this command to create it with the new project inside) - Within
larvel-project, install Zurb Foundation withcomposer require zurb/foundation - Update
setup.shto install apache withsudo apt-get install -y apache2 - Install nodejs (via installer on their website)
- Remove
"bootstrap-sass": "^3.0.0"frompackage.json(we'll be using Foundation instead) - Install sass with
npm install gulp-ruby-sass --save-dev(this will update yourpackage.jsonas well) - Run
npm install - Create
laravel-project.conf(use000-default.confin the VM as a template) insetup/and updatesetup.shto copy this file to/etc/apache2/sites-available/anda2ensiteit anda2dissitethe000-default.confand reload apache. - Add MySQL installation to
setup.shwithDEBIAN_FRONTEND=noninteractive sudo -E apt-get -q -y install mysql-server(This will leave root with no password!) - Add some "secure" stuff for MySQL into
setup.sh(check on necessity?) - Add php installation to setup script with
sudo apt-get install -y php5 php-pear - Update
resources/assets/sass/app.scssto@import "foundation.scss";and@include foundation-everythingin order to use all of Foundation - Update
gulpfile.jstomix.sass('app.scss', null, {includePaths: ["vendor/zurb/foundation/scss"]}); - Update
gulpfile.jsto include a versioning function and add comment regarding minification (gulp --production) - Install autoprefixer
npm install --save-dev gulp-autoprefixer
So, pretty much ignore everything above and do the following to use Homestead:
- Clone this repository
git clone https://github.com/MuffinTheMan/sbd-laravel.git mv sbd-laravel/laravel-project name-of-your-projectrm -rf sbd-laravelcd name-of-your-projectgit initorgit flow init(if you use git or git-flow)git add *(I also add.gitignoreand.env.examplejust cuz)composer install && npm install && npm install jquery --save- In your home directory (i.e.
~/) install Homesteadvagrant box add laravel/homesteadgit clone https://github.com/laravel/homestead.git Homesteadcd Homestead/ && bash init.sh- Modify
folders:andsites:in~/.homestead/Homestead.yamlto share the foldername-of-your-projectfrom above (and map it to whatever name you want--as an examplesites:will mapto: /home/vagrant/name-of-your-site/public - Update your
/etc/hostsfile to map192.168.10.10 name-of-your-site.app(I like usingname.dev) and flush your cache (on a Macdscacheutil -flushcache) - Run
vagrant upin~/Homestead - View your site at
name-of-your-site.app(or whatever you chose)
-
install jquery
npm install jquery --saveand mix it withfoundation/dist/foundation.js -
NOT DOING install modernizr
npm install modernizr --saveand include it inhead -
Include javascript at END of and initialize with
$(document).foundation();like:<body> <!--Place body stuff here--> <script src="js/all.js"></script> <script> $(document).foundation(); </script> </body> -
npm install motion-ui --save-dev -
Add to
includePaths'node_modules/motion-ui/src'@import 'motion-ui'; @include motion-ui-transitions;