Upload
abed-halawi
View
234
Download
1
Embed Size (px)
Citation preview
Why Do We Have Them?
Illustrate Structures
Request Http Kernel
Closure
Controller
Route Process &
Respond
DDD?Technical Debt 🤑
SOA?
• No More Legacy Code
• Defines Terminology
• Comprehensive, No Limitations
• Complements Laravel’s Design
• Simple, Yet Sophisticated
• Performs at Scale
What?
How? 🤔
Lucid • Feature• As described in business, as a class name • Runs Jobs - Steps in the process of accomplishment
CreateArticleFeature
LoginUserFeature
ControllerProcess
& RespondFeature
serve
Lucid • JobA class that does one thing; responsible for the
business logic
• CreateArticleFeature
• Validate Article Input
• Generate Slug
• Upload Files To Cdn
• Save Article
• Respond With Json
Lucid • JobA class that does one thing; responsible for the
business logic
• CreateArticleFeature
• ValidateArticleInputJob
• GenerateSlugJob
• UploadFilesToCdnJob
• SaveArticleJob
• RespondWithJsonJob
Lucid • JobA class that does one thing; responsible for the
business logic
Controller Featureserve
Validate Input
Generate Slug
Upload Files To CDN
Save Article
Respond With JSON
] Process&
] Respond
Lucid • Service• Website • ListArticlesFeature • GetPublishedArticlesJob • RespondWithViewJob
• Api • ListArticlesFeature • GetPublishedArticlesJob • RespondWithJsonJob
• Backend • CreateArticleFeature • ValidateArticleInputJob • SaveArticleJob • RespondWithViewJob
Lucid • Service• Website • ListArticlesFeature • GetPublishedArticlesJob • RespondWithViewJob
• Api • ListArticlesFeature • GetPublishedArticlesJob • RespondWithJsonJob
• Backend • CreateArticleFeature • ValidateArticleInputJob • SaveArticleJob • RespondWithViewJob
Lucid • Service• Website • ListArticlesFeature • GetPublishedArticlesJob • RespondWithViewJob
• Api • ListArticlesFeature • GetPublishedArticlesJob • RespondWithJsonJob
• Backend • CreateArticleFeature • ValidateArticleInputJob • SaveArticleJob • RespondWithViewJob
Lucid • Service
Http Kernel
WhichService?
Controller Feature
Website
Route
Controller Feature
Api
Route
Controller Feature
Backend
Route
example.com
api.example.com OR example.com/api
admin…com OR example.com/api
Domains
Lucid • Domains• Article
• GetPublishedArticlesJob
• SaveArticleJob
• ValidateArticleInputJob
• Cdn
• UploadFilesToCdnJob
• Http
• RespondWithJsonJob
Lucid • Principles ✍1. Controllers serve Features
2. Avoid Cross-Domain Communication
3. Avoid Cross-Job Communication
Getting Started> composer create-project lucid-arch/laravel my-project
1. Init a project
> lucid make:service Api
2. Scaffold a Service
> lucid make:feature Api LoginUser
3. Generate a Feature
> lucid make:job User CheckCredentials
4. Generate a Job