SlideShare a Scribd company logo
Throwing Laravel into your
Legacy™ Application
Joe Ferguson
Who Am I?
Joe Ferguson
PHP Developer
PHP Architect @ Ministry Brands
Twitter: @JoePFerguson
Organizer of @MemphisPHP
@NomadPHP Lightning Talks
Drone Racing Pilot
For Further Reading
leanpub.com/mlaphplaravelupandrunning.com
First: A Warning
Legacy Applications
“There are no solutions,
only trade offs”
- Joe Ferguson
- Paul M. Jones
- Thomas Sowell
What is a "Legacy" application
Legacy is often used for an older production
application that was written before, or without
regard for modern technologies or practices.
If you ask Wikipedia…
"... no-longer supported …"
"... maintained by an administrator that did not
develop the code …"
"... supporting older file formats ..."
https://en.wikipedia.org/wiki/Legacy_code
Modern Interpretation
"... source code inherited from someone else …"
"... source code inherited from an older version
of the software ..."
Some people say…
"Any code in production is not legacy”
"Any code written X years ago is legacy"
Legacy is all these things
As we talk about Legacy code here,
we're really talking about all of these definitions
This process is not Legacy
Specific…
Initial Project Overview
Is there a framework?
Is there a coding standard?
Is there any autoloading?
How are dependencies behind handled?
Is there an ORM or how is the database being utilized?
Is there a development environment?
Is there a framework?
Is there a coding standard?
There is a PSR for that…
How are dependencies behind
handled?
Is there an ORM or how is the
database being utilized?
Tools to help
PHP Coding Standards Fixer
http://cs.sensiolabs.org/
PHP Coding Standards Fixer
php-cs-fixer fix app --dry-run
PHP Mess Detector
https://phpmd.org
PHP Mess Detector
https://phpmd.org
$ phpmd app html cleancode --reportfile report.html
Warning about Automating
Code Changes
Triage
Address any critical things found in
Contemplation phase
PHP version issues
Fixing critical vulnerabilities
“We should just rewrite the app”
"This would be so much easier in
framework _____________”
Why not rewrite?
Progress halts entirely
Business logic is
rarely reused
Most of the time is
getting back to
current functionality
Why you should refactor
Progress continues
Business logic reused
Modernizing
functionality instead
of recreating
Make Decisions
Build Proof of Concept(s)
Ensure stakeholder buy in
Avoid the allure of green
fields**
** in some cases a rewrite is warranted
Refactoring Approach
Existing Tests
This is great!
Review the tests to get an idea of coverage
Passing tests become your control for any
upcoming changes
Confidence++
No Existing Tests
Not the end of the world!
Inspect the code base, was it written to be easily
testable?
Could you easily mock dependencies?
Untestable Code
Not all code is testable
If you can’t easily unit test the code base,
consider alternatives
Functional testing and Acceptance testing are
valid options
Acceptance Testing
NOT a replacement for Unit Testing
Test large parts of your application at a time
Can be harder to pinpoint error location
Gives large code coverage in short amount of time
Digging into the Code
Code Consolidation
Digging into the Code
Code Consolidation
Replace globals with DI
Digging into the Code
Code Consolidation
Replace globals with Dependency Injection
Write tests
Digging into the Code
Code Consolidation
Replace globals with Dependency Injection
Write tests
Extract SQL (to ORM or other)
Digging into the Code
Code Consolidation
Replace globals with Dependency Injection
Write tests
Extract SQL (to ORM or other)
Extract Business Logic (To domain logic)
Digging into the Code
Code Consolidation
Replace globals with Dependency Injection
Write tests
Extract SQL (to ORM or other)
Extract Business Logic (To domain logic)
Extract Presentation Logic to Views (Twig, Blade, etc)
Digging into the Code
Code Consolidation
Replace globals with Dependency Injection
Write tests
Extract SQL (to ORM or other)
Extract Business Logic (To domain logic)
Extract Presentation Logic to Views (Twig, Blade, etc)
Extract Action Logic (To Controllers)
Digging into the Code
Code Consolidation
Replace globals with Dependency Injection
Write tests
Extract SQL (to ORM or other)
Extract Business Logic (To domain logic)
Extract Presentation Logic to Views (Twig, Blade, etc)
Extract Action Logic (To Controllers)
Write (more) tests
Continuous Integration
Throwing Laravel into your Legacy App™
Where does Laravel fit in?
You can easily** use Laravel
components in your Legacy App
** Relatively speaking, and not all components
Laravel Component Goals
Implement Configuration
Implement Logging
Implement Routing
Implement Database
Implement Container
Configuration
https://github.com/mattstauffer/Torch/tree/master/components/config
Configuration
https://github.com/mattstauffer/Torch/tree/master/components/config
Configuration
https://github.com/mattstauffer/Torch/tree/master/components/config
Configuration
https://github.com/mattstauffer/Torch/tree/master/components/config
Configuration
https://github.com/mattstauffer/Torch/tree/master/components/config
What about secrets?
composer require vlucas/phpdotenv
composer require vlucas/phpdotenv
.env
config/app.php
Access Config the same way
Now our config is outside VCS
Do NOT version control
your .env file!
Logging
https://github.com/mattstauffer/Torch/tree/master/components/log
Logging
https://github.com/mattstauffer/Torch/tree/master/components/log
Logging
Logging
You’ll likely want to configure
your logger into a base class
that is extended
Routing
https://github.com/mattstauffer/Torch/tree/master/components/routing
Routing
https://github.com/mattstauffer/Torch/tree/master/components/routing
Routing
https://github.com/mattstauffer/Torch/tree/master/components/routing
Routing
https://github.com/mattstauffer/Torch/tree/master/components/routing
Routing
Routing
Database
https://github.com/mattstauffer/Torch/tree/master/components/database
Database
https://github.com/mattstauffer/Torch/tree/master/components/database
Database
https://github.com/mattstauffer/Torch/tree/master/components/database
Database
https://github.com/mattstauffer/Torch/tree/master/components/database
Container
https://github.com/mattstauffer/Torch/tree/master/components/container
Container
https://github.com/mattstauffer/Torch/tree/master/components/container
Container
https://github.com/mattstauffer/Torch/tree/master/components/container
Container
https://github.com/mattstauffer/Torch/tree/master/components/container
Container
https://github.com/mattstauffer/Torch/tree/master/components/container
Container
https://github.com/mattstauffer/Torch/tree/master/components/container
Containers are very powerful.
Make sure you’re not adding
spaghetti code just to shoehorn
into your App
Recap
Follow a refactoring process
Leverage Laravel components as you refactor
Make sure you write tests along the way!
Joe Ferguson
Twitter: @JoePFerguson
Email: joe@joeferguson.me
Freenode: joepferguson
Contact Info:
https://joind.in/talk/d306e
Feedback:

More Related Content

What's hot (20)

ODP
Documenting code yapceu2016
Søren Lund
 
PDF
Scrum Events and Artifacts in Action
Lemi Orhan Ergin
 
PDF
iOS Test-Driven Development
Pablo Villar
 
PPT
Code Review
rantav
 
PDF
Code Review
Tu Hoang
 
PDF
Functional Tests Automation with Robot Framework
laurent bristiel
 
PDF
Codeception Testing Framework -- English #phpkansai
Florent Batard
 
PDF
Clean Software Design - DevNot Summit Istanbul 2017
Lemi Orhan Ergin
 
PPTX
Improving Code Quality Through Effective Review Process
Dr. Syed Hassan Amin
 
PDF
DevOps & Technical Agility: From Theory to Practice
Lemi Orhan Ergin
 
PDF
Code Review: How and When
Paul Gower
 
ODP
FluentSelenium Presentation Code Camp09
Pyxis Technologies
 
PPT
Test Driven Development - Overview and Adoption
Pyxis Technologies
 
PPTX
Introduction to Aspect Oriented Programming
Amir Kost
 
ODP
A Brief Introduction to Zend_Form
Jeremy Kendall
 
PDF
Code-Review-Principles-Process-and-Tools (1)
Aditya Bhuyan
 
PDF
New Year PVS-Studio 6.00 Release: Scanning Roslyn
PVS-Studio
 
PPT
Peer Code Review An Agile Process
gsporar
 
PDF
Test Driven Design - GDG DevFest Istanbul 2016
Lemi Orhan Ergin
 
PDF
Videos about static code analysis
PVS-Studio
 
Documenting code yapceu2016
Søren Lund
 
Scrum Events and Artifacts in Action
Lemi Orhan Ergin
 
iOS Test-Driven Development
Pablo Villar
 
Code Review
rantav
 
Code Review
Tu Hoang
 
Functional Tests Automation with Robot Framework
laurent bristiel
 
Codeception Testing Framework -- English #phpkansai
Florent Batard
 
Clean Software Design - DevNot Summit Istanbul 2017
Lemi Orhan Ergin
 
Improving Code Quality Through Effective Review Process
Dr. Syed Hassan Amin
 
DevOps & Technical Agility: From Theory to Practice
Lemi Orhan Ergin
 
Code Review: How and When
Paul Gower
 
FluentSelenium Presentation Code Camp09
Pyxis Technologies
 
Test Driven Development - Overview and Adoption
Pyxis Technologies
 
Introduction to Aspect Oriented Programming
Amir Kost
 
A Brief Introduction to Zend_Form
Jeremy Kendall
 
Code-Review-Principles-Process-and-Tools (1)
Aditya Bhuyan
 
New Year PVS-Studio 6.00 Release: Scanning Roslyn
PVS-Studio
 
Peer Code Review An Agile Process
gsporar
 
Test Driven Design - GDG DevFest Istanbul 2016
Lemi Orhan Ergin
 
Videos about static code analysis
PVS-Studio
 

Similar to Throwing Laravel into your Legacy App™ (20)

PDF
So You Just Inherited a $Legacy Application...
Joe Ferguson
 
PDF
An Introduction to the Laravel Framework (AFUP Forum PHP 2014)
daylerees
 
PPT
Bridging the Gap - Laracon 2013
Ben Corlett
 
PDF
Lecture11_LaravelGetStarted_SPring2023.pdf
ShaimaaMohamedGalal
 
PDF
Eugene PHP June 2015 - Let's Talk Laravel
anaxamaxan
 
PDF
Laravel Web Development: Tools, Tips, and Insights
Shiv Technolabs Pvt. Ltd.
 
PDF
Laravel Web Development: A Comprehensive Guide
deep9753ak
 
PDF
Laravel - A Trending PHP Framework
ijtsrd
 
PPTX
Building Large Scale PHP Web Applications with Laravel 4
Darwin Biler
 
PDF
Top 10 Laravel Development Tools in 2024
GetAProgrammer
 
PPTX
Laravel introduction
Simon Funk
 
PPTX
Top 7 Reasons to Choose Laravel for Faster Web App Development.pptx
danielle hunter
 
PDF
Reasons Why Laravel is Better Over the PHP Frameworks
GetAProgrammer
 
PPTX
The trend of laravel application development will never end!
Concetto Labs
 
PPTX
Why you should use a web framework, eventually
kyphpug
 
PDF
Laravel 4 presentation
Abu Saleh Muhammad Shaon
 
PDF
Laravel Framework: A Comprehensive Guide for Modern Web Development
vitaragaistechnolabs
 
PPTX
Why Use Laravel For Developing Web Apps_.pptx
OnGraph Technologies Pvt. Ltd.
 
PPTX
8_reasons_php_developers_love_using_laravel.pptx
sarah david
 
PDF
What is Laravel and Why Should You Choose it for Your Next Project?
Acquaint Softtech Private Limited
 
So You Just Inherited a $Legacy Application...
Joe Ferguson
 
An Introduction to the Laravel Framework (AFUP Forum PHP 2014)
daylerees
 
Bridging the Gap - Laracon 2013
Ben Corlett
 
Lecture11_LaravelGetStarted_SPring2023.pdf
ShaimaaMohamedGalal
 
Eugene PHP June 2015 - Let's Talk Laravel
anaxamaxan
 
Laravel Web Development: Tools, Tips, and Insights
Shiv Technolabs Pvt. Ltd.
 
Laravel Web Development: A Comprehensive Guide
deep9753ak
 
Laravel - A Trending PHP Framework
ijtsrd
 
Building Large Scale PHP Web Applications with Laravel 4
Darwin Biler
 
Top 10 Laravel Development Tools in 2024
GetAProgrammer
 
Laravel introduction
Simon Funk
 
Top 7 Reasons to Choose Laravel for Faster Web App Development.pptx
danielle hunter
 
Reasons Why Laravel is Better Over the PHP Frameworks
GetAProgrammer
 
The trend of laravel application development will never end!
Concetto Labs
 
Why you should use a web framework, eventually
kyphpug
 
Laravel 4 presentation
Abu Saleh Muhammad Shaon
 
Laravel Framework: A Comprehensive Guide for Modern Web Development
vitaragaistechnolabs
 
Why Use Laravel For Developing Web Apps_.pptx
OnGraph Technologies Pvt. Ltd.
 
8_reasons_php_developers_love_using_laravel.pptx
sarah david
 
What is Laravel and Why Should You Choose it for Your Next Project?
Acquaint Softtech Private Limited
 
Ad

More from Joe Ferguson (20)

PDF
Modern infrastructure as code with ansible cake fest 2021
Joe Ferguson
 
PDF
Modern infrastructure as code with ansible PyTN
Joe Ferguson
 
PDF
Slim PHP when you don't need the kitchen sink
Joe Ferguson
 
PDF
DevSpace Conf 2017 - Making sense of the provisioning circus
Joe Ferguson
 
PDF
Release and-dependency-management memphis python
Joe Ferguson
 
PDF
Composer at Scale, Release and Dependency Management
Joe Ferguson
 
PDF
Put an end to regression with codeception testing
Joe Ferguson
 
PDF
Midwest PHP 2017 DevOps For Small team
Joe Ferguson
 
PDF
All the Laravel Things – Up & Running to Making $$
Joe Ferguson
 
PDF
Console Apps: php artisan forthe:win
Joe Ferguson
 
PDF
Console Apps: php artisan forthe:win
Joe Ferguson
 
PDF
All the Laravel things: up and running to making $$
Joe Ferguson
 
PDF
Laravel Forge: Hello World to Hello Production
Joe Ferguson
 
PDF
MidwestPHP 2016 - Adventures in Laravel 5
Joe Ferguson
 
PDF
Acceptance & Functional Testing with Codeception - SunshinePHP 2016
Joe Ferguson
 
PDF
Adventures in Laravel 5 SunshinePHP 2016 Tutorial
Joe Ferguson
 
PDF
php[world] 2015 Laravel 5.1: From Homestead to the Cloud
Joe Ferguson
 
PDF
php[world] 2015 Training - Laravel from the Ground Up
Joe Ferguson
 
PDF
Madison PHP 2015 - DevOps For Small Teams
Joe Ferguson
 
PDF
ZendCon 2015 - DevOps for Small Teams
Joe Ferguson
 
Modern infrastructure as code with ansible cake fest 2021
Joe Ferguson
 
Modern infrastructure as code with ansible PyTN
Joe Ferguson
 
Slim PHP when you don't need the kitchen sink
Joe Ferguson
 
DevSpace Conf 2017 - Making sense of the provisioning circus
Joe Ferguson
 
Release and-dependency-management memphis python
Joe Ferguson
 
Composer at Scale, Release and Dependency Management
Joe Ferguson
 
Put an end to regression with codeception testing
Joe Ferguson
 
Midwest PHP 2017 DevOps For Small team
Joe Ferguson
 
All the Laravel Things – Up & Running to Making $$
Joe Ferguson
 
Console Apps: php artisan forthe:win
Joe Ferguson
 
Console Apps: php artisan forthe:win
Joe Ferguson
 
All the Laravel things: up and running to making $$
Joe Ferguson
 
Laravel Forge: Hello World to Hello Production
Joe Ferguson
 
MidwestPHP 2016 - Adventures in Laravel 5
Joe Ferguson
 
Acceptance & Functional Testing with Codeception - SunshinePHP 2016
Joe Ferguson
 
Adventures in Laravel 5 SunshinePHP 2016 Tutorial
Joe Ferguson
 
php[world] 2015 Laravel 5.1: From Homestead to the Cloud
Joe Ferguson
 
php[world] 2015 Training - Laravel from the Ground Up
Joe Ferguson
 
Madison PHP 2015 - DevOps For Small Teams
Joe Ferguson
 
ZendCon 2015 - DevOps for Small Teams
Joe Ferguson
 
Ad

Recently uploaded (20)

PPTX
Feb 2021 Cohesity first pitch presentation.pptx
enginsayin1
 
PPTX
MiniTool Power Data Recovery Full Crack Latest 2025
muhammadgurbazkhan
 
PPTX
The Role of a PHP Development Company in Modern Web Development
SEO Company for School in Delhi NCR
 
PDF
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
PPTX
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
PDF
Beyond Binaries: Understanding Diversity and Allyship in a Global Workplace -...
Imma Valls Bernaus
 
PPT
MergeSortfbsjbjsfk sdfik k
RafishaikIT02044
 
PPTX
Java Native Memory Leaks: The Hidden Villain Behind JVM Performance Issues
Tier1 app
 
PDF
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PPTX
Human Resources Information System (HRIS)
Amity University, Patna
 
PDF
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
PPTX
Migrating Millions of Users with Debezium, Apache Kafka, and an Acyclic Synch...
MD Sayem Ahmed
 
PPTX
MailsDaddy Outlook OST to PST converter.pptx
abhishekdutt366
 
PDF
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
PPTX
Comprehensive Guide: Shoviv Exchange to Office 365 Migration Tool 2025
Shoviv Software
 
PDF
GetOnCRM Speeds Up Agentforce 3 Deployment for Enterprise AI Wins.pdf
GetOnCRM Solutions
 
PPTX
Writing Better Code - Helping Developers make Decisions.pptx
Lorraine Steyn
 
PDF
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
PPTX
Engineering the Java Web Application (MVC)
abhishekoza1981
 
Feb 2021 Cohesity first pitch presentation.pptx
enginsayin1
 
MiniTool Power Data Recovery Full Crack Latest 2025
muhammadgurbazkhan
 
The Role of a PHP Development Company in Modern Web Development
SEO Company for School in Delhi NCR
 
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
Beyond Binaries: Understanding Diversity and Allyship in a Global Workplace -...
Imma Valls Bernaus
 
MergeSortfbsjbjsfk sdfik k
RafishaikIT02044
 
Java Native Memory Leaks: The Hidden Villain Behind JVM Performance Issues
Tier1 app
 
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
Human Resources Information System (HRIS)
Amity University, Patna
 
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
Migrating Millions of Users with Debezium, Apache Kafka, and an Acyclic Synch...
MD Sayem Ahmed
 
MailsDaddy Outlook OST to PST converter.pptx
abhishekdutt366
 
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
Comprehensive Guide: Shoviv Exchange to Office 365 Migration Tool 2025
Shoviv Software
 
GetOnCRM Speeds Up Agentforce 3 Deployment for Enterprise AI Wins.pdf
GetOnCRM Solutions
 
Writing Better Code - Helping Developers make Decisions.pptx
Lorraine Steyn
 
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
Engineering the Java Web Application (MVC)
abhishekoza1981
 

Throwing Laravel into your Legacy App™