Under the hood of a small laravel app Speaker: George Drakakis Github project:
You can find me on || the laravel.gr forum A bit about me. A full-stack developer with a Graphic Design & multimedia background, freelancing from 2003, located in Athens – Greece. Currently working on (L4 L5) (Drupal 7 + Laravel 5) (PHP 4 crap to L5) Also… Laravel.gr community administrator and Co- Organizer of Athens Meetup. Big fan of Arts and Culture. Co-founder of artmagazine.gr and e.t.c. …soon I’ll be a Dad thing.
Important note a lot of code will follow …so let me tell you a few things about the code first.
The OCP app What the heck is that thing in the first place? 1
The general OCP logic Your client Fills a form You create a payment Link. You are paid.
In more detail Admin panel You create a link Your client visit the payment form through the link Payment gateway validate & collects payment Client fills in the payment form Money are transferred to your bank + add on Invoicing SEND Transaction info to / Slack
Task list 1.Create an administrator panel for the links 2.Create a payment form 3. alert and push notifications to slack 4.Translatable layout and easy customization 5.Flexible coding style, so payment gateways can be swapped in the future. 6.Integration Testing of the app 7.Deployment setup
The absolute basics MVC pattern / Routing / Middleware /.env setup
MVC Model View Controller (MVC) is a method that help us separate the core of our application from the graphics (View) and the Data (Model).
ROOTING Routing is the process of taking a URI endpoint and decomposing it into parameters to determine which module, controller, and action of that controller should receive the request.
MIDDLEWARE HTTP middleware provide a convenient mechanism for filtering HTTP requests entering your application. For example, Laravel includes a middleware that verifies the user of your application is authenticated.
.env Application variables per environment + protect private data like Api keys and credentials from GIT repositories
Routing ( app/Http/routes.php )
Routing ( app/Http/adminRoutes.php )
Database Migrations We need to create the database tables first. 2
Migration Example I
Migration Example II
The admin panel Lets create some links 3
Isadmin middleware
Main Template file
Localization
Elixir for the front end.
Admin Dashboard
“ We really should take a 5min break. Right?
The payment form Its time for our client to pay their link. Here is the fun part 4
AdminPaymentsController
Payment link route
The validpayment middleware
The payment link template body
The real deal. The payment controller
The Gateway implementation I have chosen BrainTree. It could really be anything you like. 5
Injecting an interface
The interface
The BrainTree implementation
A custom service provider
@if block now works in view!
User’s login Give a payment history to authenticated users. 6
The clef routes
The clef controller action
Integration Testing Automate the testing of your app 7
Backend testing
Payment form testing
Deployment Push to live and maintenance 8
"deployer/deployer“ package
Push to live command More info at dep deploy
“ Live as if you were to die tomorrow. Learn as if you were to live forever. ~ Mahatma Gandhi
Any questions ? You can find me at ◉ Slides will be available at meetup.com Thanks!