Laravel 4 – The how, what and why for PHP people. – Create a new project



Laravel 4 – The how, what and why for PHP people. – Create a new project

0 5


learning-laravel-4

Learning Laravel 4 for PHP people

On Github nickdenardis / learning-laravel-4

Laravel 4

The how, what and why for PHP people.

Created by Nick DeNardis / @nickdenardis

Laravel 4.1

http://laravel.com

Laravel 4.1 Installer

curl http://laravel.com/laravel.phar > laravel.phar
sudo mv laravel.phar /usr/local/bin/laravel
sudo chmod 777 /usr/local/bin/laravel
                    

No longer need to use composer

Create a new project

cd ~/Sites/
laravel new projectname
cd projectname
                        

Initial permissions

                                
chmod -R 777 app/storage
                                
                            

Jeffery Way Generators

// composer.json
"require": {
    "laravel/framework": "4.1.*"
},
"require-dev":{
    "way/generators": "dev-master",
    "phpunit/phpunit": "3.7.*",
    "mockery/mockery": "0.7.*"
},
                        

.editorconfig

curl https://gist.github.com/nickdenardis/8616001/raw/.editorconfig > .editorconfig
                    

https://github.com/sindresorhus/editorconfig-sublime

Install Clockwork Debugger

Chrome Extension

Laravel Service

Development Environment

Vagrant Config

curl https://gist.github.com/nickdenardis/8615920/raw/Vagrantfile > Vagrantfile
curl https://gist.github.com/nickdenardis/1a7c988e258d6d1affaf/raw/install.sh > install.sh
                    

Database Config

 array(
        'mysql' => array(
                'driver'    => 'mysql',
                'host'      => 'localhost',
                'database'  => 'project',
                'username'  => 'root',
                'password'  => 'local',
                'charset'   => 'utf8',
                'collation' => 'utf8_unicode_ci',
                'prefix'    => ''
            )
    )
);
?>
                    

Local Development Config

detectEnvironment(function(){
    return getenv('ENV') ?: 'local';
});
?>
                    

Sequel Pro

Use the SSH Tunnel to connect to the database through Vagrant.

/etc/hosts

127.0.0.1  project.dev
                    

Vagrant Up

Install Vagrant

vagrant up
vagrant ssh
http://project.dev/
                    

Testing

Install PHPUnit

curl https://phar.phpunit.de/phpunit.phar > phpunit.phar
chmod +x phpunit.phar
sudo mv phpunit.phar /usr/local/bin/phpunit
                        

Or.. Install PHPUnit

// composer.json
    "require": {
        "laravel/framework": "4.1.*",
        "doctrine/dbal": "~2.3"
    },
    "require-dev":{
        "way/generators": "dev-master",
        "phpunit/phpunit": "3.7.*",
        "mockery/mockery": "0.7.*",
        "itsgoingd/clockwork": "1.*"
    },
                        

sudo subl /etc/paths
vendor/bin
                        

Configure the Database

Create a /app/config/testing/database.php file.

 array(
        'mysql' => array(
            'driver'    => 'mysql',
            'host'      => 'localhost',
            'database'  => 'project',
            'username'  => 'root',
            'password'  => 'local',
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => ''
        )
    )
);
?>
                        

Running Tests

vagrant ssh
cd /vagrant
phpunit
                        

Laravel PHPUnit Documentation

http://laravel.com/docs/testing

Random Usefulness

THE END

Nick DeNardis (@nickdenardis)