#mavidurakio  

Özgür Adem Işıklı

Ahir Ar-Ge Danışmanlık

PHP, JS, Node.JS

Python, C++

@iozguradem

i.ozguradem@gmail.com

"The PHP Framework For Web Artisans"

Goodies

  • MVC
  • Blade (Template Engine)
  • Auth
  • Session
  • Asset Management
  • Validation
  • Unit testing
  • Cache
  • Composer & Symfony
  • Facades
  • Routing
  • Service container
  • Eloquent orm
  • Request
  • Schema builder 
  • Migration
  • Console

Composer ve Symfony

{
	"name": "laravel/laravel",
	"require": {
		"laravel/framework": "5.0.*"
	},
	"require-dev": {
		"phpunit/phpunit": "~4.0",
		"phpspec/phpspec": "~2.1"
	},
	"autoload": {
		"classmap": [
			"database"
		],
		"psr-4": {
			"App\\": "app/"
		}
	}
}
composer create-project laravel/laravel --prefer-dist

"Security"

Facades

class Cache extends Facade {

    /**
     * Get the registered name of the component.
     *
     * @return string
     */
    protected static function getFacadeAccessor() { return 'cache'; }

}
Cache::get('key');
Session::get('key');
View::make('index', ['title' => 'Hello World!']);

"Easy"

Routing

Route::get('/', function()
{
    return 'Hello World';
});
Route::get('user/{id}', function($id)
{
    return 'User '.$id;
});
Route::get(
    'user/profile', 
    [
        'as' => 'profile', 
        'uses' => 'UserController@showProfile'
    ]
);

"Easy"

Service Container

class PurchasePodcastHandler {

    /**
     * The mailer implementation.
     */
    protected $mailer;

    /**
     * Create a new instance.
     *
     * @param  Mailer  $mailer
     * @return void
     */
    public function __construct(Mailer $mailer)
    {
        $this->mailer = $mailer;
    }

}
$this->app->bind('Mailer', function($app)
{
    return new Mailer();
});

"Testable"

Eloquent ORM

class User extends Eloquent {

    protected $table = 'my_users';

}
$users = User::all();
$user = User::find(1);

var_dump($user->name);
$model = User::where('votes', '>', 100)->firstOrFail();
$user = new User;

// $user = User::find(1);

$user->name = 'John';

$user->save();

"No SQL!"

Eloquent ORM (Relationships)

class Post extends Eloquent {

    public function comments()
    {
        return $this->hasMany('Comment');
    }

}
$comments = Post::find(1)->comments;

"Flexibility"

Request

class UserController extends Controller {

    /**
     * Store a new user.
     *
     * @param  Request  $request
     * @return Response
     */
    public function store(Request $request)
    {
        $name = $request->input('name');

        //
    }

}
$name = Request::input('name');
$name = Request::input('name', 'Sally');

"Security"

Schema Builder

Schema::create('users', function($table)
{
    $table->increments('id');
    $table->string('email');
    $table->string('name', 100);
});
Schema::table('users', function($table)
{
    $table->string('address');
});
$table->integer('user_id')->unsigned();
$table->foreign('user_id')->references('id')->on('users');
$table->foreign('user_id')
      ->references('id')->on('users')
      ->onDelete('cascade');

"Teamwork"

Migration

php artisan make:migration create_users_table
php artisan migrate
php artisan migrate:rollback

"Teamwork"

Console

sh-3.2# php artisan 
Laravel Framework version 4.2.16

Usage:
  [options] command [arguments]

Options:
  --help           -h Display this help message
  --quiet          -q Do not output any message
  --verbose        -v|vv|vvv Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
  --version        -V Display this application version
  --ansi              Force ANSI output
  --no-ansi           Disable ANSI output
  --no-interaction -n Do not ask any interactive question
  --env               The environment the command should run under.

Available commands:
  changes                     Display the framework change list
  clear-compiled              Remove the compiled class file
  down                        Put the application into maintenance mode
  dump-autoload               Regenerate framework autoload files
  env                         Display the current framework environment
  help                        Displays help for a command
  list                        Lists commands
  migrate                     Run the database migrations
  optimize                    Optimize the framework for better performance
  routes                      List all registered routes
  serve                       Serve the application on the PHP development server
  tail                        Tail a log file on a remote server
  tinker                      Interact with your application
  up                          Bring the application out of maintenance mode
  workbench                   Create a new package workbench
asset
  asset:publish               Publish a package's assets to the public directory
auth
  auth:clear-reminders        Flush expired reminders.
  auth:reminders-controller   Create a stub password reminder controller
  auth:reminders-table        Create a migration for the password reminders table
  • CMS
  • Small Projects
  • Startups

Özgür Adem Işıklı

@iozguradem

i.ozguradem@gmail.com

Tech Talk #001 - Laravel 5

By iozguradem

Tech Talk #001 - Laravel 5

Tech Talk Presentation

  • 1,172
Loading comments...

More from iozguradem