Eric Katz
Web Developer based in Columbus, OH.
Rapid Application Development
w/ Modern PHP
Tea Time // @Highlights for Children
Object-Oriented Programming in PHP
source: http://laravelbook.com/laravel-architecture/
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"laravel/framework": "5.0.*",
"php-instagram-api/php-instagram-api": "dev-master",
"pusher/pusher-php-server": "2.2.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-create-project-cmd": [
"php -r \"copy('.env.example', '.env');\"",
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
}
}
<?php
Route::get('/', function()
{
return 'Hello World';
});
Route::get('user/{id}', function($id)
{
return 'User ' . $id;
});
Route::get('user/{id}/{name}', function($id, $name)
{
return "User $id, for $name";
})
->where(['id' => '[0-9]+', 'name' => '[a-z]+']);
ActiveRecord implementation.
Model layer in MVC.
Each object instance is tied to a row in DB.
Database migration system.
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function(Blueprint $table)
{
$table->increments('id');
$table->string('name');
$table->string('email')->unique();
$table->string('password', 60);
$table->rememberToken();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('users');
}
}
<?php
class HousesController extends BaseController {
public function index()
{
$houses = House::all();
return View::make('houses.index', compact('houses'));
}
public function create()
{
return View::make('houses.create');
}
public function show($id)
{
$house = House::find($id);
return View::make('houses.show', compact('house'));
}
}
<?php
Route::get( 'homes', ['uses' => 'HousesController@index'] );
Route::get( 'homes/create', ['uses' => 'HousesController@create'] );
Route::get( 'homes/{id}/view', ['uses' => 'HousesController@show'] );
Great for handling processes that should occur during the life cycle of a request.
Let's you generate markup and views agnostic to any logic handling.
@extends('app')
@section('content')
<div class="container">
<div class="row">
<div class="col-md-10 col-md-offset-1">
<div class="panel panel-default">
<div class="panel-heading">Home</div>
<div class="panel-body">
Welcome {{ $user->name }}!
</div>
</div>
</div>
</div>
</div>
@endsection
...
<body>
<header>
<h1>Site Name</h1>
</header>
<article>
@yield('content')
</article>
<!-- Scripts -->
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.1/js/bootstrap.min.js"></script>
</body>
</html>
By Eric Katz
A presentation to go over modern PHP development practices, including introduction to object oriented PHP, Composer/Packagist.org and the rapid application development framework Laravel using LTS 5.1.