How To Install Survloop Locally with Homestead

Updated March 27, 2021 by Morgan Lesko

Install Laravel's Homestead

Survloop is built atop the Laravel PHP framework.

"Laravel strives to make the entire PHP development experience delightful, including your local development environment. Laravel Homestead is an official, pre-packaged Vagrant box that provides you a wonderful development environment without requiring you to install PHP, a web server, and any other server software on your local machine."

While working through these instructions, replace all references to "survproject" with another short directory name for your own project.

  1. Install XCode from the App Store. Open it, and accept the user agreement.
  2. Install VirtualBox: https://www.virtualbox.org/wiki/Downloads
  3. Install Vagrant: https://www.vagrantup.com/downloads.html
  4. To the command line (Mac OS Terminal, or iTerm)! Create local ssh key, if you haven't on this computer before:
    % ssh-keygen -t rsa -C "your@emailaddress.com"
  5. Install Composer, Homestead, and initialize. For this example, the work area's directory is "~/homestead", but you can adjust it as needed:
    % vagrant box add laravel/homestead
    % curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
    % cd ~/
    % git clone https://github.com/laravel/homestead.git homestead
    % cd homestead
    % git checkout release
    % bash init.sh

     

  6. Edit paths in Homestead.yaml:
    % nano Homestead.yaml

    Change the folders and sites, and setup your database:

    folders:
    - map: ~/homestead/code
    to: /home/vagrant/code
    
    sites:
    - map: survproject.local
    to: /home/vagrant/code/survproject/public
    
    databases:
    - survproject

     

  7. Auto-add project(s) to the the /etc/hosts file, and start up your new virtual server:
    % vagrant plugin install vagrant-hostsupdater
    % vagrant up


Sorry, we don't currently have instructions specific for Windows, but the documentation online should be pretty good.


Install Survloop

In your new Homestead installation, enter your directory which syncs your code base with the virtual server:

% cd ~/homestead/code

Pull down a copy of the the Survloop installation scripts, and run the one built for Homestead on Mac:

% git clone http://github.com/rockhopsoft/install-scripts
% bash install-scripts/src/homestead/survloop-mac.sh
One-Time Homebrew Install for Mac
% /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
% xcode-select --install
% brew update
% brew install perl
% brew install php@8.0
% brew services start php@8.0
% brew link php@8.0 --force
% brew link --force --overwrite php@8.0


Laravel & Survloop Installation
% cd ~/homestead
% mkdir code
% cd code
% composer create-project laravel/laravel survproject "9.0.*"
% cd survproject
% nano .env

Edit the environment file (.env) to set the URL and connect your MYSQL database:

APP_NAME="My Survloop Project"
APP_URL=http://survproject.local

DB_HOST=localhost
DB_DATABASE=survproject
DB_USERNAME=homestead
DB_PASSWORD=secret
% php artisan key:generate
% php artisan cache:clear
% COMPOSER_MEMORY_LIMIT=-1 composer require rockhopsoft/survloop
% nano composer.json
...
"autoload": {
...
"psr-4": {
...
"RockHopSoft\\Survloop\\": "vendor/rockhopsoft/survloop/src/",
}
...
}, ...

Editing config/app.php seems to still be needed:

% composer update
% nano config/app.php
...
'providers' => [
...
App\Providers\FortifyServiceProvider::class,
RockHopSoft\Survloop\SurvloopServiceProvider::class,
...
],
...
'aliases' => [
...
'Survloop' => 'RockHopSoft\Survloop\SurvloopFacade',
...
], ...
% php artisan config:clear
% php artisan route:clear
% php artisan view:clear
% echo "0" | php artisan vendor:publish --force
% composer dump-autoload


Fill Database
% perl -pi -w -e "s/\\Illuminate\\Support\\Facades\\DB::statement('SET SESSION sql_require_primary_key=0'); / /g" database/migrations/*.php
% php artisan migrate --force
% php artisan db:seed --force --class=SurvloopSeeder
% php artisan db:seed --force --class=ZipCodeSeeder
% php artisan db:seed --force --class=ZipCodeSeeder2
% php artisan db:seed --force --class=ZipCodeSeeder3
% php artisan db:seed --force --class=ZipCodeSeeder4


Initialize Survloop Installation

If everything went well, this script should preload the system CSS before you open your first page in the browser, and just returns a smiley face:

% curl http://survproject.local/css-reload

Browse to the home page, and it should prompt you to create the first admin user account:
http://survproject.local

If everything looks janky, then manually load the style sheets, etc:
http://survproject.local/css-reload

After logging in as an admin, this link rebuilds many supporting files:
http://survproject.local/dashboard/settings?refresh=2


Then you should be able to open the home page, and log in.
http://survproject.local


 

New To Laravel?

Here are some of the basic lessons I've learned in my first years with Laravel...

Clearing Caches

You've made changes, but they aren't taking root. You might be able to turn that off and on again with one the common cache clears. These can be run from your Laravel installation's root:

$ php artisan vendor:publish --force
$ php artisan cache:clear
$ php artisan route:cache
$ php artisan view:clear
$ php artisan config:cache

New To Composer?

Here are some of the basic lessons I've learned in newb land...

$ composer dump-autoload
An open source project by Morgan Lesko as
Rockhopper Software Designs logo
Survloop.org content is under
Creative Commons
2015-2021