Laravel Development with Vessel (Docker)

Getting started with Vessel

I have started using Vessel for my local development as it makes starting and developing a project so much easier. It seems more lightweight than Homestead and the start-up time is much quicker than Homestead.

No PHP or Composer? No problem

If you don’t have PHP7 or Composer installed on your machine, you can follow these instructions to help get you started. It will install PHP7 and Composer environments with Docker and allowing you to create a Laravel project and install Vessel as a package.

I also add /docker folder into my .gitignore as vessel will create this upon initialisation. You could also ignore the vessel and docker-compose.yml files as well, but I enjoy keeping it within my projects.

Bash Commands

Vessel is a bash file and allows you to run any artisan, yarn or npm command of your choosing which makes it easier rather than ssh’ing into a homestead box or running the exec command.

Only for development environments

It has fantastic documentation and should allow you to get running within 10 minutes. The only downside to Vessel is that it’s only for development work and not production. So don’t expect Lets Encrypt certificates or deployment strategies with this.

Want to learn more about going from Development to Deployment? I will be live streaming a learning event Laravel: from development to deployment

If you enjoyed this article, please follow for more. Alternatively, you can Buy me a coffeeBuy me a coffee


5 of the best Laravel books

Cross development problems

Laravel – Up and Running: A Framework for Building Modern PHP Apps |

Matt Stauffer

What sets Laravel apart from other PHP web frameworks?

Speed and simplicity, for starters. This rapid application development framework and its vast ecosystem of tools let you quickly build new sites and applications with clean, readable code. With this practical guide, Matt Stauffer-a leading teacher and developer in the Laravel community-provides the definitive introduction to one of today’s most popular web frameworks. The book’s high-level overview and concrete examples will help experienced PHP web developers get started with Laravel right away. By the time you reach the last page, you should feel comfortable writing an entire application in Laravel from scratch.

Dive into several features of this framework, including: Blade, Laravel’s powerful, custom templating tool Tools for gathering, validating, normalizing, and filtering user-provided data Laravel’s Eloquent ORM for working with the application’s databases The Illuminate request object, and its role in the application lifecycle PHPUnit, Mockery, and PHPSpec for testing your PHP code Laravel’s tools for writing JSON and RESTful APIs Interfaces for file system access, sessions, cookies, caches, and search Tools for implementing queues, jobs, events, and WebSocket event publishing Laravel’s specialty packages: Scout, Passport, Cashier, Echo, Elixir, Valet, and Socialite

Laravel 5.1 Beauty: Creating Beautiful Web Apps in Laravel 5.1 |

Chuck Heintzelman

Leverage the power of Laravel 5.1 to create a simple, clean and beautiful blogging application and the administration area required to maintain the blog. This book goes through the process of designing, creating, and coding a real-world application using Laravel. You’ll learn about: * Installing Laravel 5.1 * Using Homestead * Using Elixir * Database Migrations and Seeding * Form Requests * Views (Blade templates) * Authentication * And much, much more!

Build APIs You Won’t Hate: Everyone and their dog wants an API, so you should probably learn how to build them |

Phil Sturgeon (Author), Laura Bohill (Designer)

API development is becoming increasingly common for server-side developers thanks to the rise of front-end JavaScript frameworks, iPhone applications, and API-centric architectures. It might seem like grabbing stuff from a data source and shoving it out as JSON would be easy, but surviving changes in business logic, database schema updates, new features, or deprecated endpoints can be a nightmare.

After finding many of the existing resources for API development to be lacking, Phil learned a lot of things the hard way through years of trial and error. This book aims to condense that experience, taking examples and explanations further than the trivial apples and pears nonsense tutorials often provide.

By passing on some best practices and general good advice you can hit the ground running with API development, combined with some horror stories and how they were overcome/avoided/averted. This book will discuss the theory of designing and building APIs in any language or framework, with this theory applied in PHP-based examples.

Learning Laravel’s Eloquent |

Francesco Malatesta

Learning Laravel’s Eloquent starts off by taking you through setting up your first project and guiding you in creating a perfect Laravel environment. You will learn how to build the right database structure with the Migrations system and the Schema Builder class. Next, you will be introduced to the main element of Eloquent: the model. After treating the model as a single, isolated entity, you will learn how to create relations between them. You will be taken through organizing, filtering, and sorting your data with collections. You will then learn to enhance an application with new features using events and by creating new observers. Towards the end of the book, you will discover how to install, configure, and use the Eloquent ORM without Laravel. The book concludes by walking you through how to deal with complex problems and build advanced and flexible systems.

Design Patterns in PHP and Laravel |

Kelt Dockins

Learn each of the original gang of four design patterns, and how they are relevant to modern PHP and Laravel development. Written by a working developer who uses these patterns every day, you will easily be able to implement each pattern into your workflow and improve your development. Each pattern is covered with full examples of how it can be used.

Too often design patterns are explained using tricky concepts, when in fact they are easy to use and can enrich your everyday development. Design Patterns in PHP and Laravel aims to break down tricky concepts into humorous and easy-to-recall details, so that you can begin using design patterns easily in your everyday work with PHP and Laravel.

This book teaches you design patterns in PHP and Laravel using real-world examples and plenty of humor.



If you’re looking forward to what Laravel 5.3 has to offer then I would definitely recommend that you watch this video of Taylor Otwell which goes into detail on what the latest version has to offer. It is pretty long at 1 hour and 36 minutes, but my gosh is it worth it.

Laracon US – Laravel 5.3 overview

The last two days I have been keeping an eye on the Laracon US live stream shown on [StreamACon]( and while the first day of the stream didn’t go too well, the second days stream has been phenomenal (Review will be coming soon).

The reason for this post however, is to talk about the new features in Laravel 5.3 and oh boy has he put a lot in.

First off, he has removed a lot of unneeded folders, but these can be placed back in by running the simple artisan commands for when they are actually needed by the user. This makes the framework look a whole lot cleaner and less scary for newcomers. I have seen it time and time again where a newcomer will come into Reddit and they want to know all about every folder as soon as they can when it shouldn’t be like that, they need to learn to start small and grow the framework which is exactly what 5.3 has tackled.

## Laravel Passport ##

Laravel Passport adds oAuth 2 and JWT tokens. A lot of people are already jumping on the “goodbye Dingo, hello Passport” bandwagon, but I don’t think people should be too quick to say this. It looks to me as Passport could be the perfect companion for Dingo. Dingo was never meant as a authentication layer and is in fact a JSON API layer to help with JSON requests and responses. No where has Taylor said that Passport will be doing the same, he just said it adds oAuth 2 and JWT.

## Laravel Mailable ##

This is a nice option for sending mail, it makes for a more expressive API design choice and helps tidy up the sending of mail. If you send a lot of Mail and have used the less expressive syntax, you can move to something like this…

Mail::to(‘[email protected]’)->send(new ContactForm)

Within your ContactForm class, you can build up the request and then return a Blade view on the response.

## Laravel Scout ##

This is a pretty exciting new feature which allows full text searching using Algolia (Taylor currently only has the Algolio drivers, but asks that the community adds more drivers).

php artisan scout:import App\Post

Running the above command will sync your Post model to Alogolia for indexing, you can then run searches like…


You can even paginate the responses…


## Laravel Notifications ##

Laravel notifications enable you to notify you or a customer if something happens using Slack, SMS or email.

$this->line(‘Thank you for joining’)
->action(‘Button Text’, ‘’)
->line(‘If you have any question, please reply to this email.’)

Or if you have an error…

$this->line(‘We are sorry, but something went wrong…’)
->action(‘Button Text’, ‘’)

## VueJS ##

VueJS has been added as the default JS framework into the boilerplate of Laravel 5.3. This is easy enough to take out, but is very helpful if you want to use VueJS and even helps if you couldn’t decide between VueJS, Angular or ReactJS.

## Laravel Summary ##

As you can see, Taylor had a lot to talk about and there’s bound to be something which has been missed. Taylor tried to squeeze as much in as possible, but I don’t think he had enough time to discuss everything in detail. We will have to wait a couple of weeks to see what the official release brings.

The beginning of our Laravel social network

A long while back, I said I would love to create and document making a social networking website using the Laravel framework, well that hasn’t happened, like at all.

Instead, I have started to build an API based in Lumen which I hope to open source once the main functionality has been built into it.

Once the API starts to take shape, I would then like to build an open source website which interacts with the API and then also open source the website.

Developers will then have a choice, they can either connect to whatever data I have on my server with the website repo. Or they can clone both the API and website and build out whatever it is they need for their own website.

Hopefully this will be made clear when it becomes open sourced and more people contribute to it. As I develop things further, I will throw everything up on my Blog to keep everyone who wants to follow it up to date.

Using View Composers in Laravel 5.2

I have started using Laravel’s View Composers which come in handy when you have a navigation bar that constantly needs certain data. For example, you have an ecommerce store and you need to poll how many items a user has in their basket on pretty much every page they move onto, or you need a login/register button when a user isn’t logged in and then a profile options button when they are.

You could be really lazy and add the same code/query into every single controller, which yes, that will work, but then that’s not DRY (Don’t Repeat Yourself). To fix this, we can complete a couple of simple steps and have one bit of code which will constantly be in use every time a certian partial is called.

If you currently have a layout/template view which has the navigation menu already written in, then you will need to move this out into a partial. Within your “resources > views” directory, you will need to create a new directory called “partials”. Once done, you will need to create a “nav.blade.php” file and paste in your navigation code. It should look something like this…

Next, in your layout or template blade, you can add…

This will include your navigation file.

Now for setting up the View Composer, firstly we need to setup a ServiceProvider (for the sake of this tutorial I will show a example for counting a basket)…

o’partials.nav’, ‘AppHttpViewComposersBasketComposer’
o * Register the service provider.
o *
o * @return void
o */
opublic function register()
The service provider will run whenever you use the nav partial and in the next attribute, it will use your BasketComposer which should look something like this…

ocart = Cart::Contents();
o * Bind data to the view.
o *
o * @param View $view
o * @return void
o */
opublic function compose(View $view)
o$view->with(‘cart’, $this->cart[‘result’][‘total_items’]);

Obviously, depending on your API or personal use, your code should vary here, but you should get an idea of how this is working. Everytime we need the nav partial, the view will be rendered with our given items. This can also be passed to many views at once which makes it work really well. I also believe you can pass many different constant data sets into a single view, so you could in theory also add a user constant for log in and edit profile data.

For more information, feel free to visit Laravel’s documentation on [View Composers]( and this nice [Laracasts video]( which helped me figure out how to use it correctly.

If you have a unique use case, please let me know and we can discuss as a community just how useful these View Composers are.