a introduction to laravel framework

Post on 10-Feb-2017

627 Views

Category:

Art & Photos

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

A INTRODUCTION TOLARAVEL FRAMEWORKDevZone@MegaAds.vnPhult.contact@gmail.com, phamanhtuan206@gmail.comHanoi. Jan 09, 2016

CONTENT

About MegaAds Technical Team Laravel Framework Overview Laravel v4 Laravel v5 MegaAds & Laravel

MEGAADS TECHNICAL TEAM

Business Coupon Affiliate in US Retailer in Vietnam

Systems Coupon affiliate websites Link Crawler, Link Management Retail websites Order management Inventory management CRM Tracker SEO supplier system

MEGAADS TECHNICAL TEAM

Solutions PHP, AngularJS, Laravel Framework Java, Spring Framework NodeJS, Adu Framework: https://github.com/phult/adu Search engine: Elasticsearch Message queue: Gearman Database: MySQL, Redis

LARAVEL OVERVIEW

Developer: Taylor Otwell Release: June 2011 Stable Release: 5.2.7, Dec 31, 2015 PHP: 5.3 Docs: http://laravel.com/docs, https://laracasts.com/

LARAVEL OVERVIEW

LARAVEL OVERVIEW

LARAVEL OVERVIEW

LARAVEL 4

Composer Artisan CLI Folder structure Main classes Blade template Databases ORM

Validation Cache  Event Queue IoC

COMPOSER

A tool for dependency management in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you

PHP: 5.3.2+ Equivalent:

Java: maven, gradle Ruby: gem Nodejs: npm

COMPOSER

Composer.json

COMPOSER

Command php composer.phar install php composer.phar update php composer.phar dump-autoload

ARTISAN CLI

php artisan command

PROJECT FOLDER STRUCTURE

App Config Controllers Database Lang Models Start Storage Tests Views

Bootstrap Public vendor

MAIN CLASSES

Config App.php: debug, timezone, providers Cache.php: drivers file/redis/mecache/apc/array Database.php: connections, driver mysql/redis/mongo… Mail.php Queue: driver sync/beanstalkd/sqs/iron/redis Session.php: drivers

file/cookie/database/redis/mecache/apc/array View.php: 'paths' => array(__DIR__.'/../views'),

MAIN CLASSES

Routes.php

MAIN CLASSES

Filters.php

BLADE TEMPLATE

views/front-end/layout/master.blade.php

BLADE TEMPLATE

index.blade.php

DATABASE: MIGRATION

Migration

DATABASE: MIGRATION

Migration: php artisan migrate php artisan migrate:rollback php artisan migrate:reset

DATABASE: SEEDING

Seeding

DATABASE: SEEDING

Seeding php artisan db:seed --class=UserTableSeeder

MODEL/ORM

Models/User.php

MODEL/ORM

Create: User::create([“username”=>”ABC”]);

Update User::find(1)->update([“username”=>”ABC”]);

Delete User::find(1)->delete

MODEL/ORM

Get: $user = User::find(1); $roles = User::find(1)->roles; $users = User::where(“status”,”=”,”active”

->orWhere(“status”,”=”,”active”)->find([“id”,”username”,”status”]);

DB::table(“user”)->where(“status”,”=”,”active”)->orWhere(“status”,”=”,”active”)->find([“id”,”username”,”status”]);

MODEL/ORM

EventUser::creating(function($user) { if ( ! $user->isValid()) return false; });User::created(function($user) {});User::updating(function($user) {});User::deleting(function($user) {});

VALIDATION

CACHE

Drivers: file/redis/mecache/apc/array

EVENTS

Subscribe to an event

Fire a event

QUEUES

Publish a job onto the queue

Job handler

Queue::push('SendEmail@fire', array('message' => $message),'emails');

IOC

Bind to container

Usage

LARAVEL 5

WHAT IS NEW

NEW FOLDER STRUCTURE

App/models -> remove App/Http (Controllers,Middleware,Requests)

App/start -> App/Providers App/views -> App/Resourses

DOTENV

Instead of a variety of confusing, nested environment configuration directories, Laravel 5 now utilizes DotEnv by Vance Lucas

ROUTE MIDDLEWARE

HTTP middleware provide a convenient mechanism for filtering HTTP requests entering your application

php artisan route:middleware DemoMiddleware

ROUTE & CONFIG CACHE

php artisan route:cache php artisan route:clear php artisan config:cache php artisan config:clear

FORM REQUESTS

Laravel 5.0 introduces form requests, automatically be validated.

LARAVEL SCHEDULER

Developers have generated a Cron entry for each task they need to schedule

LARAVEL ELIXIR

Elixir makes it a cinch to get started using Gulp to compile your Less, Sass, and CoffeeScript …

AUTHENTICATION

User registration, authentication, and password reset controllers are now included out of the box, as well as simple corresponding views

LARAVEL SOCIALITE

Socialite supports Facebook,Twitter, Google, and GitHub

EVENT & LISTENER

Event classes are typically stored in the app/Events directory, while their listeners are stored in app/Listeners

FLYSYSTEM

Integrations : Laravel - Symfony - Zend Framework - CakePHP - Yii 2 …

Adapters : Local - Amazon Web Services - Rackspace Cloud Files - Dropbox - Ftp - Sftp - Zip - WebDAV - PHPC - Azure Blob Storagev

TINKER / PSYSH

php artisan tinker

CONTRACTS

Laravel's Contracts are a set of interfaces that define the core services provided by the framework

MEGAADS & LARAVEL

Controller: Frontend, Backend, Services: RESTful webservice View with AngularJS: AJAX request SOA with IoC, AbtractService class Seach engine: Elasticsearch Async, RPC with Message queue: gearman

SEARCH SERVICE CONFIG

MEGAADS & LARAVEL

RPC

Gearman serverWeb App (PHP)

Node.js app

Java app

Web App (PHP)

MEGAADS & LARAVEL

Producer (PHP)

MEGAADS & LARAVEL

Consumer(Java)

top related