Categories
Fixing Stuff Laravel Samuel

combining css and js files into 1 http request

install gulp onto the server:

1.) upload the files (gulpfile.js) and (package.json) into the root directory of the site (make sure to update file paths to the correct css and js directory’s first)

2.) ssh into the server and run: npm install, do this in the same root directory you just uploaded both files to. (if this errors out just manually upload all needed node_modules files to the root directory)

3.) make sure the node_modules directory and all sub directory can execute files (chmod +x directory_name -R)

4.) execute the combining script to combine all the js and css files (./node_modules/gulp/bin/gulp.js) must be run from root directory of site or else will fail

5.) change out the javascript and css script files to the new combined file for each

If all went according to plan you now limited your css and js files down into 1 http request respectively and minifid them both.

general notes:

if you upload a new file or edit a file in the css or js directory you have to ssh into the server and run:

./node_modules/gulp/bin/gulp.js

*this generates the new combined file
*would be a good item to add to a deploy script

If the page errors out (or white screens of death) explcitly define the order of the js files in your gulpfile.js. What most

Categories
Laravel Samuel

Initial Laravel Setup Checklist

This post is merely a checklist reminder for myself and not meant to be a tutorial. If you are looking for a tutorial on setting up laravel for the first time please go to:

http://www.nowordsbarred.com/setting-laravel-4-first-time-onwamp-server/

 

    1. install laravel 5 via composer (composer createproject laravel/laravel preferdist)
    2. make deploy script for server (chmod +x script after uploading it)
    3. connect server to repo with deploy keys
    4. clone repo onto production server manually
    5. create symlink to public folder of laravel
    6. install composer in laravel directory
    7. create database
    8. define DB creds in .env file

Thats all the needed steps for getting a laravel site configured on the server.

 

1.) To allow the server to connect to the Code Base repo we need to run (cd ~/.ssh). Then run (cat id_rsa.pub) and copy the pub key file (control + insert + c to copy from terminal)… maximize the SSH terminal window if getting invalid key warning from CB, spacing seem to effect this. (If no file present run ssh-keygen). Next step is login to CB, hit the repos page, then hit the gear icon > deployment keys > ad new ssh key > past key into this window and save.

2.) When you upload your deploy script file, to give it proper permissions to execute we need to run (chmod +x script-name)

3.) To create our symlink path to the public folder we want to run:
ln -s /home/user/git/repo-name/public /home/user/public_html/public_html

or if you want to install laravel in a subfolder you can run:
ln -s /home/user/git/project/repo-name/public /home/user/public_html/directory/folder-name

**Notes**
-you must delete the public_html folder if its is already present, most systems will make this folder by default when the account is created.
-you must include the full file path, including /home/username if your are on cpanel

Categories
Laravel Samuel

Random laravel notes

kept running into this strange error for a few minutes tonight, but finally got to the bottom of it.

if you are getting “reflectionException” “controllerName does not exists” this is because you already have the controller created in your route.php file. Remove it from routes.php (or comment it out the save). Now run the command again and it will succeed.

 

how to make laravel controllers via command line:

controller:make MarketingController

when there is a conflict in tortise git:

-click on the file in conflict, hit git stash
-pull down the new code
-right click on the white space in the folder (not on the actual file) hit stash pop (this will merge your stashed file with the new one)
-commit then push

 

if php artisan migrate is not working, just run php artisan migrate:refresh and it will run the latest migrations.

if you are running DB seeders and getting an error, to find out what file the error is in run: php artisan db:seed -v this will spit out the error info of what file the seeder breaks on and what line specifically breaks it.

Categories
Fixing Stuff Laravel

installing node.js on windows 7 computer

Installing node.js on my windows 7 machine  was a bit of a struggle so I wrote down the notes:

 

1.) Install node.js from their site.  Just use the big green button, download the installer

2.) Run their auto installer and then open up git bash (note open it up in the project folder you are attempting to install bower in)

3.) If your using windows you will need to install node.js then set your environment variables (start > run > environment variables > path > edit ) then add this line to the end “;C:\Program Files\nodejs”

4.) Open up git bash and type “npm install” (if you get an error you will just need to manually create the “npm” folder in (C:\Users\your-user\AppData\Roaming ).  *replace your-user with your current user, and also its possible your file path will be different, if a different file path is echo’d out in the command prompt then use that file path.

5.) you should be able to type “npm” and load the node package manager, once that loads you can type “bower install” and load bower then you should be all set to use data tables (or whatever you loaded node.js into your project to do)

 

Categories
Fixing Stuff Laravel Samuel

Setting up Laravel 4 for the first time onWAMP server

This post is meant as a helpful guide for setting up laravel 4 on a windows machine with WAMP server installed.  The process is a little cumbersome so I wanted to jot down the steps.  Hopefully these notes on setting up laravel on local windows dev environment help someone out there on the interwebs… and I’m sure I will refer back to these on occasion.

–edit–

for a list of helpful php artisan commands please refer to the bottom of this page

–end edit–

1.) Enable openSSL in wamp server (allows us to install composer which is step #2)

  • From the wamp tray icon hit php > php extensions > php_openSSL (note we also need both php_curl & php_socket enabled for later steps)
  • restart wamp server
  • navigate to and open (C:\wamp\bin\php\php-5.4.3\php.ini).  Search for openssl and remove the comment in front of the line (then save the file)
  • now were ready to install composer

2.) Install Composer.  On windows you can install composer by downloading this setup file (https://getcomposer.org/Composer-Setup.exe)

  • if you did not enable openssl correctly you will get the following error (The openssl extension is missing, which will reduce the security and stability of Composer. If possible you should enable it or recompile php with –with-openssl).  If you get this error go back and re-visit ((C:\wamp\bin\php\php-5.4.3\php.ini).  openSSL needs to be enabled in this file for composer to install
  • now open up the command prompt and navigate to the directory you will store laravel in and install composer.  e.x.  CD C:\wamp\www\laravel) then type “composer install”.  The install will run and provide you feedback on if it was successful or not.

—-helpful note for newer version of wamp server—-
after installing a new version of wamp server you might have an issue using composer (you will have to re-install it and re-setup your environment varialbes to get it to work). Even after that though if your getting the following error when trying to run composer install then the steps below will help: /c/ProgramData/ComposerSetup/bin/composer: line 10: php: command not found

  • : Open git bash
  • go to your work directory like if you have wamp then c:/wamp/www.
  • type “composer” if you can see the composer command list then its installed correctly
  • type “composer self-update”.

Once the update runs you will be able to then navigate to your project directory and run “composer install”.

3.) Add PHP to windows environment variables

  • start > environment variables for your account > Path > edit (now chose the path variable under “user variables”)
  • add (C:\wamp\bin\php\php5.5.12) so full line will look like: (C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\wamp\bin\php\php5.5.12)

4.) Download Sqlite

5.) Download gitbash (http://git-scm.com/downloads).

  • this is not needed but it is a nicer user interface than the default windows command prompt
  • you can navigate to a file, right click > git bash, then command prompt opens up in this directory… no need to cd into the directory manually

6.) Run first local migrations

  • make a local database config file in (app\config\local\database.php)
  • change the default to sqlite (line 29 ‘default’ => ‘sqlite’,)
  • change the directory path to ../storage/database/ (line 51 ‘database’ => __DIR__.’/../../storage/database/production.sqlite’,)
  • open git bash in your laravel directory
  • run “php artisan migrate” (if having problems using local config run php artisan –env-local migrate)

7.) Run laravel on local environment

  • navigate to your laravel directory (either through windows command prompt, or by going to the file right clicking and hitting git bash)
  • type “php artisan serve”
  • go to http://localhost:8000

 

Hopefully these notes help someone out there in the interwebs.  Getting laravel up and running for the first time can feel like a somewhat daunting task, but the rewards of being able to work on a local environment are definitely worth it…. and a real plus to using sqlite is that you technically don’t even have to start wamp server now to test your local site. Once you have the local config files setup, you can open git bash, run php artisan serve and then artisan takes care of serving your actually website on localhost 8000…. which is pretty neat.

 

–random helpful notes & commands —

-runing migrations, open git bash in the laravel directory, and run: “php artisan migrate”

-to detect local and production environments edit bootstrap/start.php

$env = $app->detectEnvironment(array(
‘local’ => array(‘homestead’, ‘computer-name’),
‘production’ => array(‘server-name’),
));

 

//to detect what your server/computer name is locally put this in the top of the starts.php file and navigate to any page

echo gethostname();exit();

-to seed the db run “php artisan db:seed”

  • to do seeds and migrations locally run “php artisan –env-local migrate” and or  “php artisan –env-local db:seed”
  • if getting an error of “cant replicate database seeder” run “composer dump-autoload”