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-laravel
repo withcd sbd-laravel && rm -rf .git
- If you want to use git, run
git init
(orgit-flow init
if you're a git-flow person) - Ensure you have Composer and Node installed
- In the
laravel-project
directory runcomposer install
(orphp composer.phar install
) andnpm install
- Note: you could rename the
laravel-project
directory as well, just be aware that you would also have to updatesetup.sh
,laravel-project.conf
andVagrantfile
to 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 up
to 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.scss
withimport 'import_me'
- Run
gulp
(inlaravel-project
) to compile sass - Run
gulp watch
to 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 ofsetup
andlaravel-project
on your machine- If you get an error such as
The host path of the shared folder is missing: setup
, you need to ensure the foldersetup
has 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 checkexports
If there are errors, try editing/etc/exports
and deleting everything within, thenvagrant destroy -f; vagrant up
should do the trick!
- If you run into issues such as
- Create
setup/setup.sh
andchmod a+x
it--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/bin
toPATH
- This may be done by adding (or updating)
~/.profile
and then sourcing it. ~/.profile
(see sample.profile
inmisc
folder)
- This may be done by adding (or updating)
- Create your project with
laravel new laravel-project
(note that this becomes thelaravel-project
that 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.sh
to 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.json
as well) - Run
npm install
- Create
laravel-project.conf
(use000-default.conf
in the VM as a template) insetup/
and updatesetup.sh
to copy this file to/etc/apache2/sites-available/
anda2ensite
it anda2dissite
the000-default.conf
and reload apache. - Add MySQL installation to
setup.sh
withDEBIAN_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.scss
to@import "foundation.scss";
and@include foundation-everything
in order to use all of Foundation - Update
gulpfile.js
tomix.sass('app.scss', null, {includePaths: ["vendor/zurb/foundation/scss"]});
- Update
gulpfile.js
to 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-project
rm -rf sbd-laravel
cd name-of-your-project
git init
orgit flow init
(if you use git or git-flow)git add *
(I also add.gitignore
and.env.example
just cuz)composer install && npm install && npm install jquery --save
- In your home directory (i.e.
~/
) install Homesteadvagrant box add laravel/homestead
git clone https://github.com/laravel/homestead.git Homestead
cd Homestead/ && bash init.sh
- Modify
folders:
andsites:
in~/.homestead/Homestead.yaml
to share the foldername-of-your-project
from above (and map it to whatever name you want--as an examplesites:
will mapto: /home/vagrant/name-of-your-site/public
- Update your
/etc/hosts
file to map192.168.10.10 name-of-your-site.app
(I like usingname.dev
) and flush your cache (on a Macdscacheutil -flushcache
) - Run
vagrant up
in~/Homestead
- View your site at
name-of-your-site.app
(or whatever you chose)
-
install jquery
npm install jquery --save
and mix it withfoundation/dist/foundation.js
-
NOT DOING install modernizr
npm install modernizr --save
and 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;