I had the opportunity to speak at Prairie Dev Con on the topic of Laravel. Despite my nervousness I was happy to see lots of my friends in attendance at the conference. I have embedded my slide deck here. The talk is intended as an introduction to frameworks and Laravel in general.

  • Overview In this session we will explore the benefits of the Laravel framework, how to get started, and how to build an efficient platform using this powerful PHP framework. We will look at the code behind a simple application written in Laravel and dissect some of the interesting components. By the end of this talk you will be ready to start exploring PHP and Laravel for yourself.
  • This is a pretty basic introduction to Laravel, if you have experience in the subject you may find it more beneficial to just jump in and start playing. Check out our Docker integration: https://github.com/atrauzzi/laravel- drydock

You can find the sample GitHub project here: https://github.com/CMDann/thor

  1. What Is Laravel? A modern framework built for creating high quality applications The most scalable framework for building platforms Essentially the community standard for PHP application development A solid foundation for applications of any size Laravel has been used by my shop to create many applications for small and large businesses. It replaces the need for PaaS offerings like Google App Engine and Azure when mixed with Docker and Rancher. We get full control over our applications.
  2. Routing Routing is extremely easy in Laravel. A single file allows you to define all the custom routes you need and tell the application where to send your users and post their data. Define types GET POST PUT Route::get(‘/’, function() { return ‘Hello World’; }); Route::post(‘foo/bar’, function() { return ‘Hello World’; }); Route::put(‘foo/bar’, function() { // }); Route::delete(‘foo/bar’, function() { // });
  3. 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. If the user is not authenticated, the middleware will redirect the user to the login screen. However, if the user is authenticated, the middleware will allow the request to proceed further into the application. Of course, middleware can be written to perform a variety of tasks besides authentication. A CORS middleware might be responsible for adding the proper headers to all responses leaving your application. A logging middleware might log all incoming requests to your application. There are several middleware included in the Laravel framework, including middleware for maintenance, authentication, CSRF protection, and more. All of these middleware are located in the app/Http/Middleware directory. Directly from the Laravel documentation: https://laravel.com/docs/5.0/middleware
  4. Controllers Like all modern frameworks you have your models and controllers. This particular controller will give us each of the puppies in our system.
  5. Migrations Migrations are the easiest way to manage the data in your database when starting your system. They define your database objects and the models in the system. It is easy for new users to pick up your application and work with it. In the example the down function is not shown, down is used for when the data is deleted.
  6. The Views Your views are found under /resources/views. They are the HTML and visual components that are served by your application. The views can be organized under subdirectories and make it easy to reuse visual components and template data into your application. If you are familiar with Rails, you will enjoy the blade system in Laravel.
  7. Running the project To actually run the project locally we’re going to want to run a few commands. Composer is used to grab all our vendor dependencies. You will also create the database by running our migrations and the server can be run locally with a single command. composer update composer install php artisan migrate php artisan serve –port=8080
  8. A Simple Laravel Blog
  9. The Goal Create a simple blog that can handle user login and post updates using a WYSIWYG editor. The repository can be found here: https://github.com/CMDann/th or
  10. The Database In production you will likely use a database like MySQL or PostreSQL, since we are doing local development we will use SQLite. In our .env file we will set up our connection type to be SQLite. The connection configurations are under /config/database.php
  11. Take a moment to look at the code https://github.com/CMDann/thor
  12. Support Resources
  13. Laravel Help Docs https://laravel.com/docs/5.2 A collection of help articles and tutorials. This is the official Laravel documentation and probably your first go to place for learning about Laravel. The documents can be changed to suite your version of Laravel if for example you’re working in an older version.
  14. Laracasts https://laracasts.com/ A podcast and collection of help articles to help you cover a wide range of topics. I have had success finding help with issues that have been quite obscure.
  15. Laravel Github https://github.com/laravel/laravel Of course the easiest place to get help with issues you are having with Laravel. Just like any open source community you can also submit changes for issues you are able to fix.
  16. Larachat http://larachat.co/ The official Laravel Slack group. You can join and contribute to the discussion here. A good place to bounce ideas off people and get help when you need it. Also a good place to offer help to others.
  17. Take It To The Next Level
  18. What To Do Next? Look at Laravel Drydock https://github.com/atrauzzi/larav el-drydock Drydock integrates Docker and Laravel to make it easy to develop locally Explore the learning resources Build a simple application for yourself Join Larachat Contribute on github