Laravel on MAMP Setup

Screen Shot 2014-01-27 at 1.41.23 PM As I mentioned in my post on PHP setup on MAMP, I’m looking into CodeIgniter (post here) and Laravel.

I’ve only just started and it’s rough b/c there’s so much out there on Lavarel 3 that it’s easy to get going on something only to find it not work quite as described. Then there’s some things that point out the differences btwn 3 and 4… but I don’t know 3 so…

I’m considering signing up for laracasts.com and plowing thru their material… plowing. We’ll see.

However, I did go thru some setup and some tutorials. Andrew Perkins and Jeffrey Way have a lot of links out there. Jeffrey Way seems to be ‘Mr. Laravel’ from what I can tell and since he’s behind laracasts.com, I’ll probably go that route.

My priorities are 1) it be current 2) it be beginner-to-winner and 3) it be video (from my experience, video tutorials are great – seeing it happen, doing it w/ the video, etc. – it’s the best).

Regardless, here’s my notes on what I did in setting up Laravel and going thru some videos (towards the bottom I started seeing more 3 vs 4 differences and sought other sources)…

_________________________________________________

Laravel

http://laravel.com/ 

tuts:

http://www.laracasts.com

http://www.thenerdary.net/post/52067531360/laravel-4-primer

http://andrewperkins.net/laravel

http://jasonlewis.me/laravel-tutorials

https://tutsplus.com/lesson/installation-and-composer/

https://tutsplus.com/course/whats-new-in-laravel-4/

Install: http://laravel.com/docs/installation

Create new project: laravel new <dir name to create for project>

—————————————————

http://andrewperkins.net/laravel

Andrew Perkins – video 1 – Installation and Configuration

– in created dir: (use the php in MAMP for the MCrypt stuff)

/Applications/MAMP/bin/php/php5.5.3/bin/php artisan key:generate

Or

export PATH=/Applications/MAMP/bin/php/php5.5.3/bin:$PATH

And then just use php

– mod_rewrite is enabled by default (I believe)

—————————————————

Andrew Perkins – video 2 – Migrations and Artisan

../../bin/php/php5.5.3/bin/php artisan migrate:install

– database.php – (‘root’ password for me)

In MAMP: phpMyAdmin -> users

Migrations – interface into MySQL

Create a migration:

../../bin/php/php5.5.3/bin/php artisan migrate:make create_authors_table

– creates file: app/database/migrations/<appropriatename>

up changes, down reverts up method actions

– edit up to create table using schema builder

Run unapplied migrations:

../../bin/php/php5.5.3/bin/php artisan migrate

Create migration to add rows into authors table:

../../bin/php/php5.5.3/bin/php artisan migrate:make add_authors

– edit newly created file – use fluent query builder

Run unapplied migrations:

../../bin/php/php5.5.3/bin/php artisan migrate

Undo migrations:

../../bin/php/php5.5.3/bin/php artisan migrate:rollback

Failed – do this:

/usr/local/bin/composer.phar dumpautoload

Then again:

../../bin/php/php5.5.3/bin/php artisan migrate:rollback

(does first undo – table rows)

Run again to remove table.

Reset db (undo all migrations):

../../bin/php/php5.5.3/bin/php artisan migrate:reset

—————————————————

Andrew Perkins – video 3 – Controllers, Actions, Passing Data and Routing

Controllers

– file = class name (class name in file capitalized + _Controller)

– extends Base_Controller (now BaseController in 4)

Actions

– name: ‘action_’…

OR RESTful…

 

View

(e.g., index (view/file name) view for authors (dir) authors/index.php

– index.php (cd be index.blade.php – uses Laravel’s Blade templating engine)

Route (url to controller action)

Route::get(‘authors’, ‘authors@get_inde­x’); // controller and action specified

 

 

 

 

 

 

 

 

 

Comments are closed.