How To Install Survloop Locally with Homestead

 

Install Homestead & Laravel

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

Locally On A Mac

Replace all references to "survloop" with a short 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 to:
    folders: 
        - map: ~/homestead/code
          to: /home/vagrant/code
    
    sites:
        - map: survloop.local
          to: /home/vagrant/code/survloop/public

     

  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


$ cd ~/homestead
$ mkdir code $ cd code $ composer create-project laravel/laravel survloop "8.0.*"
$ cd survloop

Edit the environment file to connect the default MYSQL database:

$ nano .env
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret

You could do things like install Laravel's out-of-the-box user authentication tools, and push the vendor file copies where they need to be:

$ php artisan make:auth
$ echo "0" | php artisan vendor:publish --tag=laravel-notifications

 

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

From your Laravel installation's root directory, update `composer.json` to require and easily reference Survloop:

$ nano composer.json
...
"require": {
	...
    "rockhopsoft/survloop": "^0.2",
	...
},
...
"autoload": {
	...
	"psr-4": {
		...
		"RockHopSoft\\Survloop\\": "vendor/rockhopsoft/survloop/src/",
	}
	...
}, ...

After saving the file, run the update to download Survloop, and any missing dependencies.

$ composer update

Laravel Config

Add the package to your application service providers in `config/app.php`.

$ nano config/app.php
...
'providers' => [
	...
	RockHopSoft\Survloop\SurvloopServiceProvider::class,
	...
],
...
'aliases' => [
	...
	'Survloop' => 'RockHopSoft\Survloop\SurvloopFacade',
	...
], ...

Migrate, Publish, and Clean Up

Update composer, publish the package migrations, etc...

$ cd ~/homestead/code/survloop
$ echo "0" | php artisan vendor:publish --force
$ php artisan migrate
$ composer dump-autoload
$ php artisan db:seed --class=SurvloopSeeder
$ php artisan db:seed --class=ZipCodeSeeder
$ php artisan db:seed --class=ZipCodeSeeder2
$ php artisan db:seed --class=ZipCodeSeeder3
$ php artisan db:seed --class=ZipCodeSeeder4
$ php artisan optimize:clear

For now, to apply database design changes to the same installation you are working in, depending on your server, you might also need something like this...

$ chown -R www-data:33 app/Models
$ chown -R www-data:33 database

You might need to re-run some things outside the virtual box too, e.g.

$ exit
$ cd ~/homestead/code/survloop
$ php artisan optimize:clear
$ composer dump-autoload

Now you should be able to confirm your successful installation by pulling up https://survloop.org in your browser! You can also connect to the database with apps like Sequel Pro, and default login info.... Host: 192.168.10.10 , Username: homestead , Password: secret , Port: 3306 , Database: homestead .

Initialize Survloop Installation

Then browsing to the home page should prompt you to create the first admin user account:

https://survloop.org

If everything looks janky, then manually load the style sheets, etc:

https://survloop.org/css-reload

After logging in as an admin, this link rebuilds many supporting files:

https://survloop.org/dashboard/settings?refresh=2

You can also connect to the database with apps like Sequel Pro, and default login info.... Host: 192.168.10.10 , Username: homestead , Password: secret , Port: 3306 , Database: homestead .

 

New To Laravel?

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

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
$ php artisan optimize

New To Composer?

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

$ composer dump-autoload

 

Apply & Test Survloop Code Changes

Of course, you can push code changes up to GitHub and pull them back down with Composer. But if you want to avoid doing a deeper Composer update, these steps will

Run the one built for Homestead on Mac:

% bash ~/homestead/code/install-scripts/src/homestead/samples/repopush.sh

You can edit the top of this script to map the directories of:

  • your working copy of Survloop repositories
  • your Homestead code directory which sync with the virtual server
  • the sub-directory for this installation
REPODIR="~/repos"
HOMEDIR="~/homestead/code"
INSTDIR="survloop"

By default, this script assumes Laravel was installed into ~/homestead/code/survloop, and you might have tried editing a Survloop controller like ~/repos/survloop/src/Controllers/Survloop.php.


To manually push changes to your Survloop installation on Homestead, replace each repository's src root directory within the vendor:

~/homestead/code/survloop/vendor/rockhopsoft/survloop/src
~/homestead/code/survloop/vendor/rockhopsoft/survloop-libraries/src
~/homestead/code/survloop/vendor/your-vendor/your-package/src
Then, if you changed any View files, you'll need to publish:
% cd ~/homestead/code/survloop
% echo "0" | php artisan vendor:publish --force

And, if you changed and Route files, or want to be extra certain you're getting the latest code, then it can't hurt running this:

$ php artisan optimize:clear
$ composer dump-autoload

 

Updated: September 29, 2020