SlideShare a Scribd company logo
Building Scalable
applications with Laravel
Laravel - PHP Framework For Web Artisans
Lumen
The stunningly fast micro-framework by Laravel.
Lumen is the perfect solution for
building Laravel based
micro-services and blazing fast APIs
Laravel ● Middleware
● Dependency Injection
● Filesystem / Cloud Storage
● Queues
● Task Scheduling
● Database
○ Query Builder
○ Migrations
○ Seeding
● LUCID Architecture
Middleware
HTTP middleware provide a convenient mechanism for filtering
HTTP requests entering your application.
● Maintenance
● Authentication
● CSRF protection
MeetingMogul
Validate twilio requests (Header Signature)
<?php
namespace AppHttpMiddleware;
use Log;
use Closure;
use AppRepositoriesTwilioAccountTwilioAccountRepositoryInterface;
class ValidateTwilioRequestMiddleware
{
/**
* Handle an incoming request.
*
* @param IlluminateHttpRequest $request
* @param Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!$this->validateRequest($request)) {
throw new SymfonyComponentHttpKernelExceptionUnauthorizedHttpException('Twilio', 'You are not authorized to access this
resource.');
}
return $next($request);
}
}
Dependency Injection
Laravel provides a convenient way to inject dependencies
seemlessly.
<?php
namespace Database;
class Database
{
protected $adapter;
public function __construct(AdapterInterface $adapter)
{
$this->adapter = $adapter;
}
}
<?php
namespace AppApiv1Controllers;
use AppApiTransformersMessageStatusTransformer;
use AppRepositoriesUserUserRepositoryInterface;
/**
* Message Resource
*
* @Resource("Message", uri="/messages")
*/
class MessageController extends BaseController
{
protected $userRepo;
public function __construct(Request $request, UserRepositoryInterface $userRepo)
{
parent::__construct($request);
$this->userRepo = $userRepo;
}
protected function setMessagingStatus(Request $request)
{
$this->userRepo->createOrUpdateProfile($this->auth->user(), $request->all());
return (['message' => 'Message Status updated successfully.']);
}
}
<?php
namespace AppRepositories;
use IlluminateSupportServiceProvider;
class RepositoryServiceProvider extends ServiceProvider
{
/**
* @var array
*/
protected $bindings = [
UserUserRepositoryInterface::class => UserUserRepository::class,
BuddyBuddyRepositoryInterface::class => BuddyBuddyRepository::class,
ProfileProfileRepositoryInterface::class => ProfileProfileRepository::class,
ContentContentRepositoryInterface::class => ContentContentRepository::class,
];
/**
* @return void
*/
public function register()
{
foreach ($this->bindings as $interface => $implementation) {
$this->app->bind($interface, $implementation);
}
}
}
Cloud Storage
Laravel provides a powerful filesystem abstraction. It
provides simple to use drivers for working with Local
filesystems, Amazon S3 and Rackspace Cloud Storage. Even
better, it's amazingly simple to switch between these
storage options as the API remains the same for each system.
Cloud Storage
public function updateAvatar(Request $request, $id)
{
$user = User::findOrFail($id);
Storage::put(
'avatars/'.$user->id,
file_get_contents($request->file('avatar')->getRealPath())
);
}
Queues
The Laravel queue service provides a unified API across a
variety of different queue back-ends.
$job = (new SendReminderEmail($user))->onQueue('emails');
$this->dispatch($job);
Available Queue Drivers:
Database, Beanstalkd, Amazon SQS, Redis, and synchronous
(for local use) driver
Task Scheduling
The Laravel command scheduler allows you to fluently and
expressively define your command schedule within Laravel
itself, and only a single Cron entry is needed on your
server.
protected function schedule(Schedule $schedule)
{
$schedule->call(function () {
DB::table('recent_users')->delete();
})->daily();
$schedule->command('emails:send')->weekly()->mondays()->at('13:00');
$schedule->command('emails:send')->withoutOverlapping();
}
Database
Query Builder
Migrations
Seeding
Elequent ORM
Query Builder
DB::transaction(function () {
DB::table('users')->update(['votes' => 1]);
DB::table('posts')->delete();
});
Migrations
Migrations are like version control for your database.
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
});
Seeding
Laravel includes a simple method of seeding your database
with test data using seed classes.
<?php
use IlluminateDatabaseSeeder;
use IlluminateDatabaseEloquentModel;
class DatabaseSeeder extends Seeder
{
public function run()
{
DB::table('users')->insert([
'name' => str_random(10),
'email' => str_random(10).'@gmail.com',
'password' => bcrypt('secret'),
]);
}
}
Eloquent ORM
● Convention over configuration
● Timestamps automatically managed (Carbon)
● Soft Deleting
● Query Scopes
Eloquent ORM - Soft Delete
● Active Record implementation
php artisan make:model User --migration
<?php
namespace App;
use IlluminateDatabaseEloquentModel;
use IlluminateDatabaseEloquentSoftDeletes;
class Flight extends Model
{
use SoftDeletes;
/**
* The attributes that should be mutated to dates.
*
* @var array
*/
protected $dates = ['deleted_at'];
}
LUCID
Architecture
An Architecture is a pattern of
connected Structures.
LUCID architecture Designed at vinelab
to get rid of rotting/legacy code.
Architecture
Controller View
Model
Service/
Domain
Communicate Structures
● No more legacy code
● Defines Terminology
● Comprehensive, No limitations
● Complements Laravel’s Design
● Balance performance and design
Lucid Components
Feature
Job
Service
Lucid * Feature
● As described in business, as a class name
● Runs Jobs - Steps in the process of accomplishment
CreateArticleFeature
LoginUserFeature
Controller Feature
Serves
Controller serves Feature
Lucid * Job
A class that does one thing; responsible for the business logic
● Validate Article Input
● Generate Slug
● Upload Files To CDN
● Save Article
● Respond With Json
CreateArticleFeature
Lucid * Job
A class that does one thing; responsible for the business logic
● ValidateArticleInputJob
● GenerateSlugJob
● UploadFilesToCDNJob
● SaveArticleJob
● RespondWithJsonJob
CreateArticleFeature
Lucid * Job
A class that does one thing; responsible for the business logic
Lucid * Service
Implements Features and serves them through controllers
● Website
● Api
● Backend
Lucid * Domains
Responsible for the entities; exposing their
functionalities through Jobs
Lucid * Domains
● Article
○ GetPublishedArticlesJob
○ SaveArticleJob
○ ValidateArticleInputJob
● CDN
○ UploadFilesToCdnJob
● HTTP
○ RespondWithJsonJob
Lucid * Principles
● Controllers serve Features
● Avoid Cross-Domain Communication
● Avoid Cross-Job Communication
Best Practices
● Standards (PHP-FIG)
○ Autoloading
○ Code Style
● Interfaces
● Components
○ Carbon
○ Intervention
● Pull Requests &
● Code Reviews on GitHub
Question & Answer

More Related Content

What's hot

Laravel Starter Kit | Laravel Admin Template-ChandraAdmin
Laravel Starter Kit | Laravel Admin Template-ChandraAdmin Laravel Starter Kit | Laravel Admin Template-ChandraAdmin
Laravel Starter Kit | Laravel Admin Template-ChandraAdmin
Lorvent56
 
Laravel and CodeIgniter: pros & cons
Laravel and CodeIgniter: pros & consLaravel and CodeIgniter: pros & cons
Laravel and CodeIgniter: pros & cons
ElenorWisozk
 
Laravel - The PHP Framework for Web Artisans
Laravel - The PHP Framework for Web ArtisansLaravel - The PHP Framework for Web Artisans
Laravel - The PHP Framework for Web Artisans
Windzoon Technologies
 
Laravel
LaravelLaravel
Laravel
SitaPrajapati
 
MidwestPHP 2016 - Adventures in Laravel 5
MidwestPHP 2016 - Adventures in Laravel 5 MidwestPHP 2016 - Adventures in Laravel 5
MidwestPHP 2016 - Adventures in Laravel 5
Joe Ferguson
 
Laravel overview
Laravel overviewLaravel overview
Laravel overview
Obinna Akunne
 
Android Continuous Integration and Automation - Enrique Lopez Manas, Sixt
Android Continuous Integration and Automation - Enrique Lopez Manas, SixtAndroid Continuous Integration and Automation - Enrique Lopez Manas, Sixt
Android Continuous Integration and Automation - Enrique Lopez Manas, Sixt
DroidConTLV
 
Zen and the Art of REST API documentation - MuCon London 2015
Zen and the Art of REST API documentation - MuCon London 2015Zen and the Art of REST API documentation - MuCon London 2015
Zen and the Art of REST API documentation - MuCon London 2015
Steve Judd
 
Web presentation
Web presentationWeb presentation
Web presentation
Solaiman Hossain Tuhin
 
Testing Alfresco extensions
Testing Alfresco extensionsTesting Alfresco extensions
Testing Alfresco extensions
ITD Systems
 
Console Apps: php artisan forthe:win
Console Apps: php artisan forthe:win Console Apps: php artisan forthe:win
Console Apps: php artisan forthe:win
Joe Ferguson
 
Laravelの良いところ
Laravelの良いところLaravelの良いところ
Laravelの良いところ
fagai
 
Sbt, idea and eclipse
Sbt, idea and eclipseSbt, idea and eclipse
Sbt, idea and eclipse
Mike Slinn
 
Laravel introduction
Laravel introductionLaravel introduction
Laravel introduction
Simon Funk
 
Releasing High Quality Packages - Longhorn PHP 2021
Releasing High Quality Packages - Longhorn PHP 2021Releasing High Quality Packages - Longhorn PHP 2021
Releasing High Quality Packages - Longhorn PHP 2021
Colin O'Dell
 
Postman
PostmanPostman
How To Use Selenium Successfully (Java Edition)
How To Use Selenium Successfully (Java Edition)How To Use Selenium Successfully (Java Edition)
How To Use Selenium Successfully (Java Edition)Dave Haeffner
 
Functional Reactive Programming
Functional Reactive ProgrammingFunctional Reactive Programming
Functional Reactive Programming
Alessandro Melchiori
 
20171108 PDN HOL React Basics
20171108 PDN HOL React Basics20171108 PDN HOL React Basics
20171108 PDN HOL React Basics
Rich Ross
 
Semi Automatic Code Review
Semi Automatic Code ReviewSemi Automatic Code Review
Semi Automatic Code ReviewRichard Huang
 

What's hot (20)

Laravel Starter Kit | Laravel Admin Template-ChandraAdmin
Laravel Starter Kit | Laravel Admin Template-ChandraAdmin Laravel Starter Kit | Laravel Admin Template-ChandraAdmin
Laravel Starter Kit | Laravel Admin Template-ChandraAdmin
 
Laravel and CodeIgniter: pros & cons
Laravel and CodeIgniter: pros & consLaravel and CodeIgniter: pros & cons
Laravel and CodeIgniter: pros & cons
 
Laravel - The PHP Framework for Web Artisans
Laravel - The PHP Framework for Web ArtisansLaravel - The PHP Framework for Web Artisans
Laravel - The PHP Framework for Web Artisans
 
Laravel
LaravelLaravel
Laravel
 
MidwestPHP 2016 - Adventures in Laravel 5
MidwestPHP 2016 - Adventures in Laravel 5 MidwestPHP 2016 - Adventures in Laravel 5
MidwestPHP 2016 - Adventures in Laravel 5
 
Laravel overview
Laravel overviewLaravel overview
Laravel overview
 
Android Continuous Integration and Automation - Enrique Lopez Manas, Sixt
Android Continuous Integration and Automation - Enrique Lopez Manas, SixtAndroid Continuous Integration and Automation - Enrique Lopez Manas, Sixt
Android Continuous Integration and Automation - Enrique Lopez Manas, Sixt
 
Zen and the Art of REST API documentation - MuCon London 2015
Zen and the Art of REST API documentation - MuCon London 2015Zen and the Art of REST API documentation - MuCon London 2015
Zen and the Art of REST API documentation - MuCon London 2015
 
Web presentation
Web presentationWeb presentation
Web presentation
 
Testing Alfresco extensions
Testing Alfresco extensionsTesting Alfresco extensions
Testing Alfresco extensions
 
Console Apps: php artisan forthe:win
Console Apps: php artisan forthe:win Console Apps: php artisan forthe:win
Console Apps: php artisan forthe:win
 
Laravelの良いところ
Laravelの良いところLaravelの良いところ
Laravelの良いところ
 
Sbt, idea and eclipse
Sbt, idea and eclipseSbt, idea and eclipse
Sbt, idea and eclipse
 
Laravel introduction
Laravel introductionLaravel introduction
Laravel introduction
 
Releasing High Quality Packages - Longhorn PHP 2021
Releasing High Quality Packages - Longhorn PHP 2021Releasing High Quality Packages - Longhorn PHP 2021
Releasing High Quality Packages - Longhorn PHP 2021
 
Postman
PostmanPostman
Postman
 
How To Use Selenium Successfully (Java Edition)
How To Use Selenium Successfully (Java Edition)How To Use Selenium Successfully (Java Edition)
How To Use Selenium Successfully (Java Edition)
 
Functional Reactive Programming
Functional Reactive ProgrammingFunctional Reactive Programming
Functional Reactive Programming
 
20171108 PDN HOL React Basics
20171108 PDN HOL React Basics20171108 PDN HOL React Basics
20171108 PDN HOL React Basics
 
Semi Automatic Code Review
Semi Automatic Code ReviewSemi Automatic Code Review
Semi Automatic Code Review
 

Similar to Building Scalable Applications with Laravel

Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Laravel development (Laravel History, Environment Setup & Laravel Installatio...Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Dilouar Hossain
 
Using Apache as an Application Server
Using Apache as an Application ServerUsing Apache as an Application Server
Using Apache as an Application ServerPhil Windley
 
Why Laravel?
Why Laravel?Why Laravel?
Why Laravel?
Jonathan Goode
 
laravel-interview-questions.pdf
laravel-interview-questions.pdflaravel-interview-questions.pdf
laravel-interview-questions.pdf
AnuragMourya8
 
Memphis php 01 22-13 - laravel basics
Memphis php 01 22-13 - laravel basicsMemphis php 01 22-13 - laravel basics
Memphis php 01 22-13 - laravel basics
Joe Ferguson
 
Angular for Java Enterprise Developers: Oracle Code One 2018
Angular for Java Enterprise Developers: Oracle Code One 2018Angular for Java Enterprise Developers: Oracle Code One 2018
Angular for Java Enterprise Developers: Oracle Code One 2018
Loiane Groner
 
Intro to Laravel 4
Intro to Laravel 4Intro to Laravel 4
Intro to Laravel 4
Singapore PHP User Group
 
Serverless APIs with JavaScript - Matt Searle - ChocPanda
Serverless APIs with JavaScript - Matt Searle - ChocPandaServerless APIs with JavaScript - Matt Searle - ChocPanda
Serverless APIs with JavaScript - Matt Searle - ChocPanda
Paul Dykes
 
Extending Oracle E-Business Suite with Ruby on Rails
Extending Oracle E-Business Suite with Ruby on RailsExtending Oracle E-Business Suite with Ruby on Rails
Extending Oracle E-Business Suite with Ruby on Rails
Raimonds Simanovskis
 
Decompose the monolith into AWS Step Functions
Decompose the monolith into AWS Step FunctionsDecompose the monolith into AWS Step Functions
Decompose the monolith into AWS Step Functions
beSharp
 
Microservices and modularity with java
Microservices and modularity with javaMicroservices and modularity with java
Microservices and modularity with java
DPC Consulting Ltd
 
Divide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.jsDivide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.js
Sebastian Springer
 
Fast Web Applications Development with Ruby on Rails on Oracle
Fast Web Applications Development with Ruby on Rails on OracleFast Web Applications Development with Ruby on Rails on Oracle
Fast Web Applications Development with Ruby on Rails on OracleRaimonds Simanovskis
 
Ruby on Rails All Hands Meeting
Ruby on Rails All Hands MeetingRuby on Rails All Hands Meeting
Ruby on Rails All Hands Meeting
Dan Davis
 
Apache Samza 1.0 - What's New, What's Next
Apache Samza 1.0 - What's New, What's NextApache Samza 1.0 - What's New, What's Next
Apache Samza 1.0 - What's New, What's Next
Prateek Maheshwari
 
Knolx session
Knolx sessionKnolx session
Knolx session
Knoldus Inc.
 
Laravel & Composer presentation - extended
Laravel & Composer presentation - extendedLaravel & Composer presentation - extended
Laravel & Composer presentation - extended
Cvetomir Denchev
 
Serverless cat detector workshop - cloudyna 2017 (16.12.2017)
Serverless cat detector   workshop - cloudyna 2017 (16.12.2017)Serverless cat detector   workshop - cloudyna 2017 (16.12.2017)
Serverless cat detector workshop - cloudyna 2017 (16.12.2017)
Paweł Pikuła
 

Similar to Building Scalable Applications with Laravel (20)

Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Laravel development (Laravel History, Environment Setup & Laravel Installatio...Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Laravel development (Laravel History, Environment Setup & Laravel Installatio...
 
Using Apache as an Application Server
Using Apache as an Application ServerUsing Apache as an Application Server
Using Apache as an Application Server
 
Why Laravel?
Why Laravel?Why Laravel?
Why Laravel?
 
laravel-interview-questions.pdf
laravel-interview-questions.pdflaravel-interview-questions.pdf
laravel-interview-questions.pdf
 
Memphis php 01 22-13 - laravel basics
Memphis php 01 22-13 - laravel basicsMemphis php 01 22-13 - laravel basics
Memphis php 01 22-13 - laravel basics
 
Angular for Java Enterprise Developers: Oracle Code One 2018
Angular for Java Enterprise Developers: Oracle Code One 2018Angular for Java Enterprise Developers: Oracle Code One 2018
Angular for Java Enterprise Developers: Oracle Code One 2018
 
Intro to Laravel 4
Intro to Laravel 4Intro to Laravel 4
Intro to Laravel 4
 
Serverless APIs with JavaScript - Matt Searle - ChocPanda
Serverless APIs with JavaScript - Matt Searle - ChocPandaServerless APIs with JavaScript - Matt Searle - ChocPanda
Serverless APIs with JavaScript - Matt Searle - ChocPanda
 
Extending Oracle E-Business Suite with Ruby on Rails
Extending Oracle E-Business Suite with Ruby on RailsExtending Oracle E-Business Suite with Ruby on Rails
Extending Oracle E-Business Suite with Ruby on Rails
 
Laravel Meetup
Laravel MeetupLaravel Meetup
Laravel Meetup
 
Grails 101
Grails 101Grails 101
Grails 101
 
Decompose the monolith into AWS Step Functions
Decompose the monolith into AWS Step FunctionsDecompose the monolith into AWS Step Functions
Decompose the monolith into AWS Step Functions
 
Microservices and modularity with java
Microservices and modularity with javaMicroservices and modularity with java
Microservices and modularity with java
 
Divide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.jsDivide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.js
 
Fast Web Applications Development with Ruby on Rails on Oracle
Fast Web Applications Development with Ruby on Rails on OracleFast Web Applications Development with Ruby on Rails on Oracle
Fast Web Applications Development with Ruby on Rails on Oracle
 
Ruby on Rails All Hands Meeting
Ruby on Rails All Hands MeetingRuby on Rails All Hands Meeting
Ruby on Rails All Hands Meeting
 
Apache Samza 1.0 - What's New, What's Next
Apache Samza 1.0 - What's New, What's NextApache Samza 1.0 - What's New, What's Next
Apache Samza 1.0 - What's New, What's Next
 
Knolx session
Knolx sessionKnolx session
Knolx session
 
Laravel & Composer presentation - extended
Laravel & Composer presentation - extendedLaravel & Composer presentation - extended
Laravel & Composer presentation - extended
 
Serverless cat detector workshop - cloudyna 2017 (16.12.2017)
Serverless cat detector   workshop - cloudyna 2017 (16.12.2017)Serverless cat detector   workshop - cloudyna 2017 (16.12.2017)
Serverless cat detector workshop - cloudyna 2017 (16.12.2017)
 

Recently uploaded

De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
Jelle | Nordend
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
KrzysztofKkol1
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
Tendenci - The Open Source AMS (Association Management Software)
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
Peter Caitens
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
Software Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdfSoftware Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdf
MayankTawar1
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
vrstrong314
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
XfilesPro
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
informapgpstrackings
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
Cyanic lab
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Anthony Dahanne
 

Recently uploaded (20)

De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
Software Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdfSoftware Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdf
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 

Building Scalable Applications with Laravel

  • 1. Building Scalable applications with Laravel Laravel - PHP Framework For Web Artisans
  • 2. Lumen The stunningly fast micro-framework by Laravel. Lumen is the perfect solution for building Laravel based micro-services and blazing fast APIs
  • 3. Laravel ● Middleware ● Dependency Injection ● Filesystem / Cloud Storage ● Queues ● Task Scheduling ● Database ○ Query Builder ○ Migrations ○ Seeding ● LUCID Architecture
  • 4. Middleware HTTP middleware provide a convenient mechanism for filtering HTTP requests entering your application. ● Maintenance ● Authentication ● CSRF protection MeetingMogul Validate twilio requests (Header Signature)
  • 5. <?php namespace AppHttpMiddleware; use Log; use Closure; use AppRepositoriesTwilioAccountTwilioAccountRepositoryInterface; class ValidateTwilioRequestMiddleware { /** * Handle an incoming request. * * @param IlluminateHttpRequest $request * @param Closure $next * @return mixed */ public function handle($request, Closure $next) { if (!$this->validateRequest($request)) { throw new SymfonyComponentHttpKernelExceptionUnauthorizedHttpException('Twilio', 'You are not authorized to access this resource.'); } return $next($request); } }
  • 6. Dependency Injection Laravel provides a convenient way to inject dependencies seemlessly. <?php namespace Database; class Database { protected $adapter; public function __construct(AdapterInterface $adapter) { $this->adapter = $adapter; } }
  • 7. <?php namespace AppApiv1Controllers; use AppApiTransformersMessageStatusTransformer; use AppRepositoriesUserUserRepositoryInterface; /** * Message Resource * * @Resource("Message", uri="/messages") */ class MessageController extends BaseController { protected $userRepo; public function __construct(Request $request, UserRepositoryInterface $userRepo) { parent::__construct($request); $this->userRepo = $userRepo; } protected function setMessagingStatus(Request $request) { $this->userRepo->createOrUpdateProfile($this->auth->user(), $request->all()); return (['message' => 'Message Status updated successfully.']); } }
  • 8. <?php namespace AppRepositories; use IlluminateSupportServiceProvider; class RepositoryServiceProvider extends ServiceProvider { /** * @var array */ protected $bindings = [ UserUserRepositoryInterface::class => UserUserRepository::class, BuddyBuddyRepositoryInterface::class => BuddyBuddyRepository::class, ProfileProfileRepositoryInterface::class => ProfileProfileRepository::class, ContentContentRepositoryInterface::class => ContentContentRepository::class, ]; /** * @return void */ public function register() { foreach ($this->bindings as $interface => $implementation) { $this->app->bind($interface, $implementation); } } }
  • 9. Cloud Storage Laravel provides a powerful filesystem abstraction. It provides simple to use drivers for working with Local filesystems, Amazon S3 and Rackspace Cloud Storage. Even better, it's amazingly simple to switch between these storage options as the API remains the same for each system.
  • 10. Cloud Storage public function updateAvatar(Request $request, $id) { $user = User::findOrFail($id); Storage::put( 'avatars/'.$user->id, file_get_contents($request->file('avatar')->getRealPath()) ); }
  • 11. Queues The Laravel queue service provides a unified API across a variety of different queue back-ends. $job = (new SendReminderEmail($user))->onQueue('emails'); $this->dispatch($job); Available Queue Drivers: Database, Beanstalkd, Amazon SQS, Redis, and synchronous (for local use) driver
  • 12. Task Scheduling The Laravel command scheduler allows you to fluently and expressively define your command schedule within Laravel itself, and only a single Cron entry is needed on your server. protected function schedule(Schedule $schedule) { $schedule->call(function () { DB::table('recent_users')->delete(); })->daily(); $schedule->command('emails:send')->weekly()->mondays()->at('13:00'); $schedule->command('emails:send')->withoutOverlapping(); }
  • 14. Query Builder DB::transaction(function () { DB::table('users')->update(['votes' => 1]); DB::table('posts')->delete(); });
  • 15. Migrations Migrations are like version control for your database. Schema::create('users', function (Blueprint $table) { $table->increments('id'); });
  • 16. Seeding Laravel includes a simple method of seeding your database with test data using seed classes. <?php use IlluminateDatabaseSeeder; use IlluminateDatabaseEloquentModel; class DatabaseSeeder extends Seeder { public function run() { DB::table('users')->insert([ 'name' => str_random(10), 'email' => str_random(10).'@gmail.com', 'password' => bcrypt('secret'), ]); } }
  • 17. Eloquent ORM ● Convention over configuration ● Timestamps automatically managed (Carbon) ● Soft Deleting ● Query Scopes
  • 18. Eloquent ORM - Soft Delete ● Active Record implementation php artisan make:model User --migration <?php namespace App; use IlluminateDatabaseEloquentModel; use IlluminateDatabaseEloquentSoftDeletes; class Flight extends Model { use SoftDeletes; /** * The attributes that should be mutated to dates. * * @var array */ protected $dates = ['deleted_at']; }
  • 19. LUCID Architecture An Architecture is a pattern of connected Structures. LUCID architecture Designed at vinelab to get rid of rotting/legacy code.
  • 22. ● No more legacy code ● Defines Terminology ● Comprehensive, No limitations ● Complements Laravel’s Design ● Balance performance and design
  • 24. Lucid * Feature ● As described in business, as a class name ● Runs Jobs - Steps in the process of accomplishment CreateArticleFeature LoginUserFeature Controller Feature Serves
  • 26.
  • 27.
  • 28.
  • 29.
  • 30. Lucid * Job A class that does one thing; responsible for the business logic ● Validate Article Input ● Generate Slug ● Upload Files To CDN ● Save Article ● Respond With Json CreateArticleFeature
  • 31. Lucid * Job A class that does one thing; responsible for the business logic ● ValidateArticleInputJob ● GenerateSlugJob ● UploadFilesToCDNJob ● SaveArticleJob ● RespondWithJsonJob CreateArticleFeature
  • 32. Lucid * Job A class that does one thing; responsible for the business logic
  • 33.
  • 34.
  • 35.
  • 36.
  • 37. Lucid * Service Implements Features and serves them through controllers ● Website ● Api ● Backend
  • 38.
  • 39.
  • 40. Lucid * Domains Responsible for the entities; exposing their functionalities through Jobs
  • 41. Lucid * Domains ● Article ○ GetPublishedArticlesJob ○ SaveArticleJob ○ ValidateArticleInputJob ● CDN ○ UploadFilesToCdnJob ● HTTP ○ RespondWithJsonJob
  • 42.
  • 43. Lucid * Principles ● Controllers serve Features ● Avoid Cross-Domain Communication ● Avoid Cross-Job Communication
  • 44. Best Practices ● Standards (PHP-FIG) ○ Autoloading ○ Code Style ● Interfaces ● Components ○ Carbon ○ Intervention ● Pull Requests & ● Code Reviews on GitHub

Editor's Notes

  1. API architecture We need to use micro frameworks for APIs
  2. Laravel provides these features and it sets it apart from other PHP frameworks.
  3. Same as filters in Yii Can be defined Globally with route group
  4. Validate all requests coming from Twilio
  5. Problems DI solves are “Inversion of Control” and “Dependency Inversion Principle” Loosening dependencies by separate instantiation Depend on abstractions rather than concretions
  6. Dependency of UserRepository is injected automatically through Service Containers
  7. Service container bindings are registered in Service Providers We can replace these bindings with mock classes and testing can become simpler.
  8. Laravel uses flysystem library to provide filesystem abstraction.
  9. I guess Convention over Configuration is not specific to ORM In Laravel it has more use in ORM as compared to Ruby On Rails in which most of the framework features work on this principle
  10. Architecture: Outcome depends on how structures are connected. (DNA -> dinosaur) Old/legacy projects like Shredd/MTSobek New developer needs to understand where each piece of code resides
  11. How Structures (Classes) like any service connected to other part of our code High level or Top level view. An expression of a Viewpoint. Communicate Structures Large application code New developer MVC example
  12. Why use architecture Utility and Helper Classes Single Responsibility Principle
  13. Thin controller
  14. Autoloading (PSR-4) Code Style (PSR-2)