Why I love Laracasts

Access all articles in sprocket icon.

Published November 14, 2016 by Bill Keck.

Why I love Laracasts

I’m doing a quick post on why I love Laracasts. Now I’ve written before about how amazing Laracasts is, and how I think it is well-worth the price of subscription, especially if you are ready to move on from beginner into a more intermediate level. So rather than give a big overview, in this post, I’m going to talk about a particular lesson:

Cleaner Webhook Management

Before I start, let me mention that I’m not going to reproduce the lesson here, that would be a copyright violation and I have no intention of doing that. Laracasts is a paid service. I know it’s tough to let go of educational dollars, but Laracasts consistently delivers high quality videos that improve my programming skills, so I’m a happy subscriber. I think that’s true for most programmers that have tried it, since Laracasts has so many subscribers.

Anyway, the lesson I’m referencing above demonstrates a couple of things that I got excited about. One was using a handle method on a controller to consume different types of request data and use it to a call a conversion method dynamically. Sounds complicated, but it’s not.

What a lot of us fall into is writing if statements or switch statements to handle the different request possibilities. But that gets unwieldy when the number of possibilities from the request scales. So Jeffery Way’s implementation is a nice solution and is super clean and easy to follow.

The other thing I loved in the lesson was his use of a unit test to flush out the method and see if it was translating the request data properly. He also shows us how to filter down the unit test to just a single test or method, so you don’t have to run all your unit tests. That saves a lot of time.

All of this happens in 8 minutes and 51 seconds, so the video just moves along at a rapid pace. I’ve watched it 3 times to make sure I have a rock solid understanding of all the principles that were expressed.

Laracasts places a huge emphasis on clear, maintainable code, which means that even if you are not necessarily needing the implementation at hand, you learn a lot just by watching Jeffery Way’s approach to solving problems. There’s an art form to writing cleaner, more extensible code, so it’s always a pleasure to learn how to improve our code.

One of the things I’ve noticed about the best programmers is that they always strive to improve. If there is a way to increase their programming knowledge and speed, even if it is very incremental, they are all over it. You never know when something small can turn out to be big.

For example, at work we recently did a migration that caused the old domain cookie to become invalid. This threw off a symptom that would keep calling login, because the session was never set properly. The only answer for that is for the user to clear the cookie. Since I worked with implementing Socialite and changing the session domain, I knew what was causing the problem, as soon as I heard about. It seemed like such a trivial thing. But we were able to get the message out to customer service quickly, and they put out a site message as well, so we overcame it quickly. We would have tripped over that, were we not familiar with the issue. It’s a case where the constant learning came into play and helped out.

Learning is not a destination, it’s a journey. Laracasts, for me, has been a critical part of that journey. After 3 years of subscribing, I still find new things to be excited about…

Thanks to everyone who has and is supporting my work, sharing the journey. I don’t have a donate button, but if you would like to contribute, you may do so by buying one of my books, Laravel 5.4 For Beginners. I would really appreciate it. Shares, comments, likes, and book reviews are also greatly appreciated. See you soon.

make:social-app command released for Foundation Maker

Access all articles in sprocket icon.

Published October 23, 2016 by Bill Keck.

make:social-app command released for Foundation Maker

I pushed through the weekend and was able to get the make:social-app command done for Foundation Maker. For anyone unfamiliar with it, Foundation Maker is a free package that currently adds 19 new artisan commands.

Installation via composer is a snap. Just run the following from the command line:



composer require evercode1/foundation-maker

Then add the following to the providers array in config/app.php:



Evercode1\FoundationMaker\FoundationMakerServiceProvider::class,

Then run:



php artisan list

So if you’ve been following this blog, you know that Foundation Maker is a code generator and you can check out the docs for a full list of commands.

For now, we are going to focus on make:social-app.

The make:social-app command is intended for use with a fresh install of Laravel. It will overwrite many files, and therefore is not to be used with an existing project.

Also note, that the application the command will produce is dependent on the following packages being installed:

And obviously, you would have to have Foundation Maker installed as well. If you have read my book, you will be familiar with the code this command produces, we cover it extensively throughout the book. Again, you can check the docs to get an idea of all the files it creates for you.

The social app that Foundation Maker creates handles social authentication with one-click through facebook, but you do need to set up your facebook app and grab the credentials and paste them in your .env file for it to work. It takes less than a minute, if you have done this before.

Then all you need to do is run from the command line:



php artisan migrate

Then, if you have already done so, run the following from the command line:



npm install

And then of course, run:



gulp

I built this command for a number of reasons. I felt that having an artisan command generate the code and locate it where I would normally put things was a big advantage over setting up a package that would reside in the vendor folder. I like having just one location for my controllers, etc.

Another advantage is that I’m forced to keep the templates up-to-date. If I pulled down an archived template, for example, I wouldn’t be getting the latest version of Laravel. Sure, you can run composer update, but that doesn’t update the files that reside in your app folder.

And finally, I felt it was important to be able to seamlessly integrate the other commands that Foundation Maker provides. For example, one of those commands, make:exception, allows me to create exceptions and their corresponding views with a single command. The social-app template has a Handler.php file that makes it easy for me to integrate the new exceptions.

Thanks to everyone who has and is supporting my work. I don’t have a donate button, but if you would like to contribute, you may do so by buying one of my books, Laravel 5.4 For Beginners. I would really appreciate it. Shares, comments, likes, and book reviews are also greatly appreciated. See you soon.

Laravel 5.3 For Beginners Updated for Vue 2

Access all articles in sprocket icon.

Published October 23, 2016 by Bill Keck.

Laravel 5.3 For Beginners Updated for Vue 2

I’m happy to announce that Laravel 5.3 has been updated to use Vue 2.0.1, which is the current release of Vue.js. I’ve also added a couple of chapters that cover basic and advanced use of Foundation Maker, a free artisan plugin, giving you new artisan commands for code generation.

Updates to the book are free for the life of the book, just log in to your Leanpub.com account, and pull down the latest copy.

The update to Vue 2 was a hectic one for me, it came just as I released the first version of Foundation Maker, so I really had to scramble to not only update the plugin, but also the book.

One issue that came up was that I was unsuccessful in trying to update an earlier version of Laravel, 5.3.10. For some reason I couldn’t get that to work with Vue 2, so I ended up pulling a new install of Laravel, which was on version 5.3.18. Laravel started shipping Vue 2.01 as of Laravel version 5.3.16.

I have quite a few readers who will be caught in the transition, which is why I’m talking about it here. If you are not yet to chapter 11, and you are working with an install of Laravel that is below 5.3.16, then I would recommend doing a fresh install, and quickly copying the work you have already done into the new version. Otherwise the code from chapter 11 on will not work. Sometimes updating is a bit of a pain, but it’s worth it and you will not be disappointed. In the book, we build a fully searchable, sortable, and paginated data grid using Vue 2.

If you want to check the version of Laravel you are using, you can run the following artisan command:



php artisan -V

Staying current on a new release like Vue 2 is very important, in my opinion. There’s no sense in learning a new javascript framework if you are learning on a version that is already outdated. So that was a huge motivator for me to put in the long days and nights to get this update out to you.

The book is now over 700 pages in length. For those unfamiliar with the book, we cover the basics of REST with a front-end and back-end sample app, Socialite and Facebook one-click registration and login, Image management, admin access control, data grids with Vue 2, Foundation Maker, and charts with Charts.js and Vue.js. The book starts at the beginner level and moves towards a more intermediate level with Elixir, node.js and vue.js.

Thanks to everyone who has and is supporting my work. I don’t have a donate button, but if you would like to contribute, you may do so by buying one of my books, I would really appreciate it. Shares, comments, likes, and book reviews are also greatly appreciated. See you soon.

Foundation Maker for Laravel 5.3 Officially Released

Access all articles in sprocket icon.

Published Ocotber 8, 2016 by Bill Keck.

Foundation Maker for Laravel 5.3 Officially Released

Foundation Maker is a free package for Laravel 5.3 that adds 15 new artisan commands, including make:foundation, which let’s you stand up an entire working CURD model and views, with an ajax-powered, searchable, sortable and paginated data grid, written in Vue.js.

Adding Foundation Maker to your Laravel project is a snap. Just use call the following on your command line:



composer require evercode1/foundation-maker

Then add the following to your providers array in config/app.php:



Evercode1\FoundationMaker\FoundationMakerServiceProvider::class,

To see the new artisan commands, run the following from the command line:



php artisan list

Then you can parse through and see all the new make commands:

  • make:assets
  • make:master
  • make:crud
  • make:views
  • make:foundation
  • make:child-of
  • make:parent-child

There’s also corresponding remove commands for all commands except make:assets.

Please note, if you are unfamiliar with Foundation Maker, read the docs and tutorial, and note that it works best with a fresh install of Laravel due to the setup of assets. Run npm install after running the make:assets command.

For those of you who have purchased my book, Laravel 5.3 For Beginners, you will recognize the data grid from the book. The big difference is that the book is written using Vue.js 1.0.26, and the Foundation Maker code generator uses Vue.js 2.0.1.

I will be adding a chapter to the book to introduce Foundation Maker and the migration to Vue.js 2, and that update will be free to everyone who has purchased the book. I will be emailing out an announcement when that is ready and then you will be able to pull the latest version of the book.

Previously, for Laravel 5.2, I created a different tool, View Maker, which got over 600 downloads on packagist.org. Creating View Maker was a lot of fun and I learned a lot. But instead of updating that tool, I decided to make a clean break, since the application structure of Laravel 5.3 is different, and Foundation Maker utilizes Elixir and the code it produces is actual production-level code. Foundation Maker is much more efficient and production-ready than View Maker was.

Foundation Maker also has some advanced features that View Maker does not. For example, you have the ability to make your own custom templates and have Foundation Maker use those templates instead of the native ones it ships with. This can be really handy if you want to setup your templates with your own style, which is probably going to be the way to do it most cases.

Let’s say for example, you want to setup your Foundation templates, so that the controller flashes an alert to the view when you create a new record. The native templates don’t have that for the obvious reason that not everyone might want it. Personally, I might use Sweet Alert for that, someone else may choose something else entirely. With the custom templates, you can decide which one to use and simply write it into the template, so every time you create a foundation, it is included automatically.

So you get complete control over the templates, and also, you get to inject custom tokens if you wish, which is another new advanced feature. The tokens get replaced into the template with the actual value of the token. For example, the :::model::: token would return Widget if Widget was the name of your model. You don’t have to worry about the model token, that one is baked in, but if you do have something you want that is not included in the native token list, then you can create your own, which is a very handy feature.

Although Foundation Maker is incredibly easy to use, I’m going to create a video tutorial series for it. I’m also going to be adding a lot more to it, so look for exciting announcements on that.

There are 2 ideas driving my development on Foundation Maker. One is that I want to use artisan commands to manipulate my templates. I like having the code where I would normally put it, instead of a vendor folder. Some of us already use our IDE to create templates. But while you could create templates through your IDE, you can’t really chain them together in the way that Foundation Maker can. When you run make:foundation with Foundation Maker, for example, with that one command, you are creating the following files:

  • model
  • controller
  • api controller (if it does not yet exist)
  • migration
  • unit test
  • Queries folder (if it does not yet exist)
  • GridQueries folder (if it does not yet exist)
  • GridQueries/Contracts folder (if it does not yet exist)
  • GridQuery.php (if it does not yet exist)
  • DataQuery.php (if it does not yet exist)
  • appropriately named model query file
  • appropriately-named view folder
  • index view
  • create view
  • edit view
  • show view
  • Vue.js component file

The make:foundation command also appends to the following files:

  • routes.php
  • ModelFactory.php
  • ApiController (if it already exists)
  • components.js

That’s a lot of power wrapped up in one command. If you use the make:parent-child command, you get double that, one for both the parent and the child.

So the other idea driving my development on Foundation Maker is that I want to reduce the amount of time it takes to create an app. Laravel is an awesome framework, but there are still a lot of things you find yourself doing over and over that could be automated. Towards that end, I’ve only just begun. I want Foundation Maker to be able to help you stand up a full frontend, backend CRUD app in under an hour. It’s kind of a lofty goal, but that’s what I’m aiming for.

I have a lot of work ahead of me. I also plan to support Foundation Maker with free videos on how to use it, so keep an eye out for that announcement.

Thanks to everyone who has and is supporting my work. I don’t have a donate button, but if you would like to contribute, you may do so by buying one of my books, I would really appreciate it. Shares, comments, likes, and book reviews are also greatly appreciated. See you soon.

Top 10 Reasons Laravel Is Such A Great PHP Framework

Access all articles in sprocket icon.

Published September 23, 2016 by Bill Keck.

Top 10 Reasons Laravel Is Such A Great PHP Framework

I found writing this article a challenge because I love Laravel and it’s hard to distill that love for the framework down to a top ten list, so in that sense, I’ve failed before I have even started. On the other hand, programmers are always looking for a sense of direction. For those unfamiliar with Laravel, they may ask, ‘Why favor that framework over others?’

So I boiled it down to this list, just to provide some insight from insight from someone who not only uses the framework personally, and has written a book about it for beginners, but also as someone who has seen the benefits of using the framework at the enterprise level, since my company uses it for that.

So here we go:

1. Commitment to Excellence

Laravel, or more precisely Taylor Otwell, has a mission, which you can find in the readme.md file of any Laravel installation. Here are 3 sentences from that statement that say a lot:

Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable, creative experience to be truly fulfilling. Laravel attempts to take the pain out of development by easing common tasks used in the majority of web projects, such as authentication, routing, sessions, queueing, and caching.

Now it’s one thing to talk about expressive and elegant syntax, another thing to actually accomplish it. Laravel actually fulfills that promise and it’s done so with Taylor Otwell’s long term vision.

At this point Laravel is 5 years old. It works so well and is so intuitive, it’s easy to forget that’s the product of an evolution and the pursuit of consistent ideals.

In 2013, Taylor Otwell wrote a 67 page book that talked about his approach to Laravel. I read that book for the first time, as a beginner, in 2013, and I had no idea of what he was talking about. I reread that book a year ago and it was so cool because I could see how the framework had evolved in exactly the ways he laid out in the book.

Without doing a full review of the book, I’ll just hit a few points. He talked about escaping the limitations of the MVC architecture, the value of loose-coupling though dependency injection, and the limitations of the notion of a model in MVC.

I do recommend that book by the way, but not if you are a beginner, it will not help you with the basics. It does however offer a fascinating glimpse into Taylor Otwell’s sense of architecture. Plus, buying a book is a nice way to say thanks for all the work he has done with Laravel.

Anyway, the point of bringing up the book and talking about the evolution of Laravel is you can see what he was committed to early on and how he actually executed on it. The Laravel we know today didn’t happen by accident. It’s the result of a long-term commitment to excellence, best practices, use of SOLID design principles, and the steady vision of the founder, Taylor Otwell.

2. Constant Evolution & Growth

I started following Laravel in 2013, but did not actually use the framework itself until Laravel 5.0 came out, which was in 2015. That was the moment, to my mind, when it blew away the competition. It seems like such a long time ago, but as of this writing, it’s not even 24 months. And in that time we went through 3 more releases, which gets us to 5.3, as of this writing.

5.0 was notably different from the previous version in it’s application structure and introduced middleware, favoring that instead of filters, which brought the framework more in line with the RESTful approaches of other types of frameworks, like the Express javascript framework, for example. 5.0 also saw the introduction of the Request class, and other classes, that on the surface seemed complicated at first, but in reality greatly enhanced the simplicity of working with requests, as well as providing structural organization and code generation. It was exactly the kind of thing Taylor Otwell was talking about in his book. He was breaking free of the conventional MVC approach.

5.1 introduced long-term support, which made it ideal for enterprise work. I wrote a blog recommending it because of that. There were other changes to, but I can’t keep track of them all at this point.

In 5.2, we saw the make:auth command which created all the authentication views with a single artisan command. So you could use the out-of-the-box authentication to get up and running in under a minute and have all the functionality, including forgot password. It’s so easy. And in 5.2, they introduced login throttling to prevent attacks via login, another nice improvement.

5.3 saw a lot of changes including separating the routes file into web and api files. Stateless auth is now one of the options that you can stand up quickly by changing the config, so if you feel your project is going to scale to the point where sessions will degrade performance, you now have another option.

I won’t review all the changes, but one of the biggest changes was the inclusion of a sample Vue.js implementation that makes installing Vue.js and using it very easy to understand. Vue.js is javascript framework that is easy to use and many Laravel developers favor it.

Prior to 5.3, I wasn’t using Elixir, but with the Vue.js implementation, I finally started using it, and I have to say, it’s amazing. I have Elixir as separate item in my top ten list as well. It’s that good.

It isn’t just new features that get added to Laravel. For example, in 5.3, there is a new mailable class you can create with Artisan. There was nothing wrong with the old way of creating a mail event, but that didn’t stop them from improving it. The syntax and structure is so elegant, it’s just a pleasure to work with, which putting it that way, makes it sound like it comes right out of the mission statement in italics from the first item on this top ten list. Again, that’s not an accident.

The only downside to rapid growth and evolution is that you have to work a little harder to keep up. I have found that it is worth upgrading to the latest version in every case because I want to use one or more of the new features. To help this go smoothly, Laravel has an upgrade guide for each version available in the docs.

3. Documentation

Laravel has beautifully written and comprehensive documentation. I recommend to anyone who wishes to learn the framework to read the docs from start to finish, it’s worth your time to do it.

Sometimes great programmers struggle to communicate with the written word, but that is not the case here. Instead, we get precision and clarity and it’s very helpful. You will use the docs often.

I find myself referring back to the convenient lists of the validators and migration syntax often. It’s just so easy to use. Have a question about how to use Redirect? Just type that into the search field in the top nav, you will find what you need.

Also, and this is part of the ecosystem, the Laravel forum has many answers to common problems. One of the benefits of using a widely adopted platform is that you get the benefit of all those other programmers who have tried doing the same things as you have, and you can find their examples and solutions.

If I ask myself the question, what would I change about the Laravel Docs, the answer is simple. Nothing.

4. Elixir

Elixir, a tool written by Jeffery Way, was introduced in Laravel 5.0 as a way to manage and compile assets. So what does that mean? Well, when you use sass, a css preprocessor, you need to compile it down to css in order to be able to use. The same is true for javascript, if you are using ES6, which is not supported in all browsers.

As I mentioned above, I didn’t start using Elixir until recently because I didn’t have much of a front-end focus. But with the introduction in 5.3 of Vue.js being installed and configured out-of-the-box (after running npm install), I was motivated enough to try it. Now I wouldn’t dream of creating a project with out it.

Elixir also gives your versioning control, which stops your assets from being cached, so you don’t fall into development hell of trying to figure out why your javascript is not acting the way you want it to.

Elixir is super-clean and super-easy to work with as of 5.3. Personally, I think it’s a huge contribution to the framework. We will discuss Jeffery Way’s other huge contribution on item 10 of our top ten list, when we talk about Laracasts.

5. Out-Of-The-Box Authentication

In the 5.2 release of Laravel, we got the make:auth artisan command, which, with a single command, will create all of your auth views, including login, register, and forgot password. That’s a lot of code generation from a single command, and it is a pleasure to use.

Before you run the command, you already have the controllers and traits in place, since those ship with the framework. You also have a User model and the corresponding migrations for both the users and create_passwords tables.

The bottom line is that you can this all working within a matter of minutes, and you are getting a robust solution that includes login throttling.

I’ve enjoyed working with the Auth Controllers and traits, which are now, as of 5.3, separated into a LoginController and ForgotPasswordController. I do an implementation of Socialite for Facebook and Github, which I will talk about more later, based on the out-of-box solution.

So far, with every version release of Laravel, I’ve had to update it, since the controllers and traits are being changed, but I don’t mind. These are critical areas of the framework and I want to stay current and have access to new features and the very best that the framework has to offer.

6. Artisan & Code Generation

If you want a demonstration of self-affirming syntax, then the following explains it well:



php artisan make:

That is something you would type in your command line to do an Artisan command. Artisan is Laravel’s command line tool and it’s deep. Just to give you an idea of some of the code generation commands, here is a list of make commands:

  • make:auth Scaffold basic login and registration views and routes
  • make:command Create a new Artisan command
  • make:controller Create a new controller class
  • make:event Create a new event class
  • make:job Create a new job class
  • make:listener Create a new event listener class
  • make:mail Create a new email class
  • make:middleware Create a new middleware class
  • make:migration Create a new migration file
  • make:model Create a new Eloquent model class
  • make:notification Create a new notification class
  • make:policy Create a new policy class
  • make:provider Create a new service provider class
  • make:request Create a new form request class
  • make:seeder Create a new seeder class
  • make:test Create a new test class

If we add -m flag to make:model, we get the corresponding migration. If we add –resource to make:controller, we get 7 restful method stubs on the controller.

Obviously there is more to Artisan than I can cover in a simple list like this, but I do have to say that it is wonderful to work with. And you can tell by the different types of classes that it can generate just how helpful it is. For example, the make:test command will generate a stub, not only extending the right class for you, but also in the tests folder. So it puts the generated classes in the proper places and namespaces the for you as well. Again, it’s a pleasure to work with, and again, that’s not an accident.

7. Plays Well With Others

In a very basic sense, Laravel is a service container that holds service providers. Those service providers power the application. Many of the service providers are deferred, which means they are only called when needed. They include the core framework providers as well as providers for outside packages.

To add a service, for example, if you want to add a package, you may run the composer require command, and then add the service provider via config/app.php and also the alias if there is one. That’s a total of 2 lines and just doesn’t get any simpler.

This makes Laravel very extensible and there are thousands of packages on packagist.org that you can extend your application with. I can’t claim to have worked with some enormous number of outside packages for Laravel, but what I do know is that I never had a problem installing the ones I have used, other than the occasional typo on my part.

Laravel also comes with sensible defaults. For example, out-of-box, you care configured for mailtrap.io in your .env file. So all you have to do is use the one-click registration with your github account on mailtrap.io, grab the credentials, paste them into your .env file, and you are ready to test your forgot password emails. Total implementation time is under a minute.

Laravel is built using Symfony components. And you may ask, why not just use Symfony? I know personally for me, I found Symfony a lot harder to work with and to learn. I don’t know the current state of Symfony because I haven’t felt the need to play with it in a long time. But that’s not why I brought it up. Laravel’s core is built with Symfony, Doctrine, the Faker library, Carbon and other libraries. All of these components work flawlessly with Laravel, and to me, that says a lot about the application structure and implementation.

I don’t know that I would use a framework because it returns my created_at and updated_at fields as carbon instances, but is an example of another great detail that makes the framework a pleasure to use (see again mission statement in item 1).

With Laravel, you can set the filesystem to a non-local drive.  For example, if you wish to store your images on Amazon S3, you can easily configure Laravel to do so for you.  That is a very practical feature of the framework.

8. Eloquent

Creating, Updating and Retrieving data from the database can be a real chore. The problem stems from the fact that data is stored in smallest structures possible, for example, a user’s name in one table and their address in another. We can join these together using raw SQL, but Laravel’s syntax makes this a lot easier. With Laravel, we create methods that define the relationship, then we have access to a number of methods to get the value of a property of a relationship. It’s so simple.

I’m not going to get into the exact syntax here, but I’ll link to the eloquent docs. The fact that Taylor Otwell would name his ORM Eloquent says a lot about what he is trying to accomplish.

Laravel also has a fluent query builder, which you can use in situations where you don’t want to use Elqouent.

Often what I find is that use many of Laravel’s different ways to access data. I use DB::raw to create a select statement that formats the date a certain way. Normally, I would use Carbon for formatting, but that is not always possible when building queries dynamically.

If I just want to iterate over a collection of posts, I use Eloquent:



 $posts = Post::all();

Then you can do a foreach loop in blade to iterate over each one. I don’t know how much simpler it could be than that. Again, I’m not going to go too deep into syntax, since wordpress doesn’t cooperate with publishing code.

With big datasets, you need to pull the data out in chunks for pagination. Otherwise, if you had a large database, and you ran a query for all, you would put a strain on the DB and return more rows than are practical to display.

Fortunately, Eloquents pagination is super easy to use:



 $posts = Post::paginate(10);

So in this case, we retrieve data, paginated in groups of 10 records. I’m showing you this not for instruction because this is not a tutorial, but to show you how intuitive this syntax is.

9. Official Packages & Extensive Ecosystem

The Laravel framework has a number of extremely useful packages that we can add via composer that extend the framework. One that I’ve used often is the Socialite package.

Socialite provides 0Auth authentication via Facebook and other sites like Github. It works very well and is fairly easy to implement. Depending on how you want to implement social authentication, the implementation can be a little more complex, if for example, you want one-click registration as well as one-click login.   But Socialite eliminates the most complex parts of that and it’s just great.

I haven’t used Cashier personally, but I know some programmers who have, and they love it. Cashier provides an implementation for Stripe, which is an online payment gateway.

Laravel Passport help us quickly implement an API for stateless auth. I haven’t used this personally, but I’m excited about using it at some point in the future.

Laravel also has a number of commerical services that support it, including:

I’ve used Forge personally, and what that does is automatically configure a server, let’s say a droplet from Digital Ocean, to deploy your application. It’s pretty easy to use and the cost is low at $15. I’m not really a dev ops guy, so I found this service to be a big help.

My company uses Envoyer to deploy its applications. Envoyer helps you deploy an application instantly, without any down time. It works incredibly well.

I don’t know that much about Spark because I haven’t used it, but it’s a paid template that acts as a starting point for an application.

So those are the commercial services, with the exception of one, which I’m going to talk about in the next top ten list item.

Laravel also has the following community resources:

One of my favorites is Laravel News. I look forward to the new issue, which comes out for me on Sunday mornings. Obviously, I have used the forum on more than one occasion to find an answer to a problem.

The podcast is a lot of fun, and you typically get a behind the scenes look at what’s coming down the road.

The bottom line is that there is a lot support and learning resources available.

10. Jeffery Way & Laracasts

I couldn’t imagine pursuing my education in PHP programming without Laracasts. Laracasts is a paid video site, with numerous series that contain programming lessons on Laravel, PHP, Javascript and more. Jeffery Way does a fantastic job of explaining how things work and the concepts and design patterns that fuel the Laravel framework. With Laracasts, we learn how to think like a programmer.

I never met a single programmer that didn’t like Laracasts, no matter their skill level. I started watching Laracasts in 2013, which is when it began, if memory serves me correctly. As a beginner, back then, I struggled. Even though there are free videos for the basics on Laracasts, I didn’t quite get it. In those days, there were lots of instruction about the importance of dependency injection, but it all went over my head.

As I developed as programmer, gained experience from other frameworks, I started to understand more and I grew to really love those videos. I try not to miss an episode, regardless of the subject. He covers everything from lessons in Git to regular expressions to setting up and using Redis,  and of course everything you want to know about PHP and Laravel.

As an outsider looking in, it seems to me that Taylor Otwell and Jeffery Way share an enthusiasm for a keyword driven approach to syntax. I really connected to that more than anything else. I’ve always been fascinated by syntax, in terms of both good and bad, and how it facilitates comprehension or how it degrades it.

Both the framework and Jeffery Way’s implementations of it maximize the best aspects of syntax. Another way to say that is they make it easier to understand. I think they have probably both studied Robert Martin’s Clean Code book, which was published in 2009, but remains an iconic work.

I’ve had conversations with programmers about whether or not Laravel is suitable for beginners. A lot of them say no, but obviously I wrote a book for beginners, so I feel strongly that beginners should get started with Laravel as soon as possible. I would also say, sign up for Laracasts as soon as possible. I’m not, by the way, paid by anyone to say that. I never met Taylor Otwell or Jeffery Way, so it’s not personal. It’s just that I appreciate their influence and the impact they have had on my professional life.

One of the great things about Laracasts is that it gives you a window on to what trends are happening. For example, I first heard about Vue.js at Laracasts.

At our company, we debated for a few months whether or not we would use Vue, but that ended about 3 months ago, and now we wouldn’t dream of not using it. Everyone loves it. Laracasts has an entire series on it. Anyway, we wouldn’t have even known about Vue if not for Laracasts, which is one reason why we bought a company license.

Laracasts is a huge plus for Laravel, so much so that I would call it a competitive advantage. Having a resource like that available is another reason to love the framework.

Summary

Ok, so that’s my top ten list. I hope you enjoyed it. Like I said, it falls short of course. Maybe my next blog will be the Top 100 Laravel Features I love or something like that because there are at least that many things that I love about it.

Thanks to everyone who has followed my blogs and read my books.  Please like, share and comment if you can. I appreciate your support.

Laravel 5.3 For Beginners Book Official Release

Access all tutorials in sprocket icon.

Published September 8, 2016 by Bill Keck.

Laravel 5.3 For Beginners Book Official Release

I’m happy to announce I’ve just released my new book, Laravel 5.3 For Beginners. The book comes in at just over 620 pages, and covers a lot of ground that I did not cover in my previous Laravel books, including using Elixir and Vue.js.

The book starts out with the basics, like the previous books, and some of that will sound familiar if you read those books, but then it progresses into more intermediate code. We utilize Socialite for one-click authentication with Facebook and Github, so now we have it set up to handle multiple social providers. We have an image management trait that helps us utilize the Intervention Image package, which makes creating thumbnails very easy.

Another big difference in this book is the use of Elixir and Vue.js. I didn’t cover those in previous books because I felt they were more intermediate, and actually, Vue.js has only recently been adopted by the community to the extent that is now configured in Laravel out of the box. You will love that.

The whole Elixir implementation is easier to get going now, so we get introduced to Elixir for our asset management. But we don’t do that early in book, we save it for later, after you learn the basics.

Instead we take you step by step in building a sample application that will help you understand how the framework actually works. The early chapters are similar to my last book, but there are significant differences, mostly refinements that reflect both my personal growth as a programmer and also trends within the community. For example, while I still use the form helper for date formatting, I don’t use it for much else and we will explore the reasons for that.

Also, we are no longer using jQuery for our data grids. Instead we moved to a very robust data grid built with Vue.js, the javascript framework that is favored by so many Laravel developers, so much so, it comes setup for you out of the box, after you run npm install.

As always, I did my best to make the book comprehensive and accessible to all. Laravel is just an awesome framework, and if you are just learning, it’s a great place to start.

Thanks again to everyone who has purchased my previous books and followed this blog, I appreciate your support!

ViewMaker Screencast Now Live for Laravel 5.2

Access all tutorials in sprocket icon.

Published June 1, 2016 by Bill Keck.

ViewMaker Screencast Now Live for Laravel 5.2

ViewMaker is off to a good start, we already have over 100 installs. So I decided to support it with a screencast.

In part one, I go through installation and setup of ViewMaker.

It’s a lot of fun to make a screencast, but I have to say, I’m nowhere near the professional level of Laracasts. It’s a little low energy, compared to how my brain actually operates, and I sort of sound like a stroke victim…

Anyway, that’s ok, as long as the information is clear, we all have to start somewhere. I will get better at it as I continue to make videos.

Making a screencast, as raw as it is, is more fun than writing just a blog, so I will probably be doing more tutorials on screencasts than blogs in the future.

I especially want to support ViewMaker, which has a powerful set of artisan commands that will generate a lot of code for you quickly. I’m having a lot of fun with that and I think you will like it too.

In ViewMaker for Laravel part 2, I demonstrate the make:master command and the make:foundation command. The make:master command sets all the dependencies for make:foundation and the two commands can be run in under a minute, which will get you a fully working crud app, with a vue.js datagrid.

If you want to learn how to implement a vue.js datagrid with searchable, sortable, and paginated rows, use ViewMaker to create a foundation, then look at the underlying code. I demonstrate this in part 2:

I’m hoping the screen cast helps people learn the ViewMaker commands quickly. I will be doing videos for all the commands in the next few weeks. I also have a tutorial on the Github page, which has very thorough documentation.

I hope you find ViewMaker useful. I don’t have a donate button, but If you would like to support my work and learn more about Laravel, you can do so by buying one of my books, Laraboot: laravel 5.2 For Beginners, I really appreciate it.

ViewMaker make:chart Command released for Laravel Artisan

Access all tutorials in sprocket icon.

Published May 27, 2016 by Bill Keck.

The make:chart artisan commands from ViewMaker for Laravel 5.2

This week new features were released for ViewMaker, which now adds a total of 12 new artisan commands to the Laravel artisan command line tool. This week we picked up make:chart, remove commands, and the ability to add slugs.

For those unfamiliar with ViewMaker: It’s an artisan plugin installed via composer. It’s built to supercharge workflow for standing up complete foundations of code, everything from model and migration to controller and factory method for seeding. It even creates a unit test for your create form, and of course it creates views, with the option of a fully working datagrid.

You can build all of that in under a minute, including migrating and seeding the db table. It’s a lot of fun to use.

A quick reminder on how to install via composer, just run:



composer require evercode1/view-maker

Then in your config/app.php providers array, add the following:



Evercode1\ViewMaker\ViewMakerServiceProvider::class,

You can also refer to the docs, which have extensive descriptions and a workflow tutorial.

Before we talk about the make:chart command, let’s get caught up on the other big improvement, the slug option for make:foundation, make:crud, make:parent-child, and make:child-of.

Let’s do a Widget model example and run a foundation. Please note, you should use the make:master page to set up your master page with all the dependencies you need for the make:foundation command to work. See the docs for instructions on that, it’s very simple.

So assuming your master page has the dependencies, you can run the foundation command as follows:



php artisan make:foundation Widget master vue slug

In the above, Widget is the model you want to create, master is the name of your master page, and vue is the template type. Except for the slug, that is what was in the earlier versions of ViewMaker, which stands up the routes, model, controllers, factory method, unit test, migration, and views for a fully working, searchable, sortable, paginated datagrid in vue.js, all in one go.

What’s new is the slug flag, which defaults to false, so if you don’t want it, you don’t have to include it. But if you do want slugs on your show view, just include it like we did above, and you will get a fully-formatted and functional slug for all records, so that comes in handy.

So in this case if your first widget record had a name of ‘my first widget’, your show url would look like the following:



http://www.yourapp.com/widget/1-my-first-widget

We use the convention of the id, followed by the slug to make sure there is no duplicate content. You can of course change that to suit your needs.

ViewMaker also now features remove commands to make stepping backwards simple. For example:



php artisan remove:foundation Widget

When removing, we only need to supply the model name. This is really helpful, especially if you made a typo in creation of the foundation. You can just remove it and then do the correct command, and still get it done in under a minute.

All in all there are 5 remove commands, which makes stepping backwards on most commands very easy. Right now, however, if you want to step backwards on make:parent-child, which is essentially two related foundations, use the remove:foundation twice, once for each model.

Ok, so onto the really big feature. ViewMaker now has a make:chart command, which will stand up a vue.js implementation of chart.js. After making a foundation, which is a dependency for the chart, just run the following command:



php artisan make:chart Widget

This will create a fairly advanced chart for you and place it at the top of your index page. You can change that to suit your needs, but that is where it will default to.

The chart UI allows you to select chart type, bar or line. You can also select the following dataperiods:

  • 1 year
  • 90 days
  • 1 month
  • 1 week

Your results will be pulled from your database and displayed with the proper labels.

Formatting the data for charts is a bit of a pain. There are a lot of ways you can do it. Some people prefer to do the formatting in javascript, while others prefer php. I chose the php route, since it’s my primary cdoing language.

The formatting takes place in the ApiController, which the make:foundation command builds for you. It’s a fairly big method, and you are free to extract parts out to your model or other classes to suit your own taste. The code generated by ViewMaker gets you up and running quickly, but you should do some housekeeping by organizing it with whatever format you are comfortable with. If the project is small, you can leave it as is.

The main thing is you get a working prototype and since there are not that many out there in vue.js, this can be a big help in getting started and learning how to work with it. It’s actually fairly easy to work with, once you know your way around it.

While the chart works right out of the box, you’ll want to organize your assets. I don’t extract out the js and css for you, you have to do that on your own. The reason for that is that I have no way to know how you are organizing your assets, whether you are using Elixir or not, so I leave those decisions to you.

Ultimately, using Elixir is probably the best choice, if you are ready to work with that. Consult with Laracasts for how to use Elixir, they have an awesome series on that.

All of ViewMaker features a very minimal bootstrap implementation, which leaves a lot of decisions up to you on how you want to customize it. The bootstrap that it does have is enough for you to get a clear idea of everything, while at the same time, keeping it simple, so you can do your own design.

Well, that’s it for now. More will be coming…

I hope you find ViewMaker useful. I don’t have a donate button, but If you would like to support my work and learn more about Laravel, you can do so by buying one of my books, Laraboot: laravel 5.2 For Beginners, I really appreciate it.

ViewMaker make:parent-child Laravel Artisan Command Released

Access all tutorials in sprocket icon.

Published May 16, 2016 by Bill Keck.

The make:parent-child and make:child-of artisan commands from ViewMaker for Laravel 5.2

I’m happy to announce the release of a couple of new commands for ViewMaker. For the sake of anyone who is unfamiliar with ViewMaker, it’s an artisan plugin, available free from packagist.org. To install it:



composer require evercode1/view-maker

Then in your config/app.php providers array, add the following:



Evercode1\ViewMaker\ViewMakerServiceProvider::class,

Now when you run:



php artisan list

You will see the following commands have been added to your list of artisan commands:

  • make:child-of
  • make:crud
  • make:master
  • make:foundation
  • make:parent-child
  • make:views

These will appear in alphabetical order in your commands list.

So even though the plugin is called ViewMaker, you can see it obviously does a lot more than just create views. For example, a make:foundation stands up the following:

  • model
  • controller
  • api controller (if it does not yet exist)
  • migration
  • test
  • appropriately-named view folder
  • index view
  • create view
  • edit view
  • show view

And the foundation command appends to:

  • routes.php
  • ModelFactory.php
  • ApiController (if it already exists)

You can get all of this instantly and this can really supercharge your workflow. After running the command, you migrate, run your unit test, and factory seed. The whole sequence can be done in under a minute and then you have a fully populated datagrid to play around with.

If you are just starting out with vue.js and want to see a working datagrid that gets its data from an ajax call, this is great way to learn, since it will stand that up for you instantly.

The exact requirements for the make:foundation command is on the Github site, so I won’t repeat it here, since we are moving on to discussing the new commands:

  • make:child-of
  • make:parent-child

I created these commands to cover situations when you want to create, for example, Category and Subcategory, and you want full UI to be able to add, edit and delete them easily. So the make:parent-child command let’s you define both the parent and the child in one go and stands up a foundation for each. In addition to that, it includes the relationships and the extra column on the datagrid for the child model to show the corresponding parent model. It’s a lot of code that goes up instantly.

If we follow this example, then the command would look like this:



php artisan make:parent-child Category Subcategory master vue

The parent comes first followed by the child. Then you indicate the name of your master page (I stick to master for that), and finally, the template type you want. In this case I have selected vue to get the datagrid built in vue.js, which features robust pagination, column sorting and search.

Don’t forget to run php artisan migrate after commands like make:foundation that have a migration, otherwise the datagrid is not going to work.

Now of course there are situations where you don’t think of the child model until after you have made the parent, and for that, we would use the make:child-of command, which would almost look the same as the previous command:



php artisan make:child-of Category Subcategory master vue

In this case, you will only modify the parent to add the has many relationship and it will create a foundation for the child, along with the extra code to relate it to the parent.

Remember that there are dependencies that the datagrid requires, and you easily get them by running the make:master command if you are starting with a fresh install of Laravel, which is the recommended way to play around with ViewMaker. You will have all your dependencies in place instantly.

If you want to use the make:foundation or any of the other commands with an existing Laravel app, then consult the Github page to make sure you have included the dependencies.

Well, that’s it for now. I have more planned for ViewMaker. I hope to be able to release more commands soon.

Click on the sprocket icon at the top of the page to see all my Laravel articles and tutorials. Please comment, share, like and review if you can, thanks.

I don’t have a donate button, but If you would like to support my work and learn more about Laravel, you can do so by buying one of my books, Laraboot: laravel 5.2 For Beginners, I really appreciate it.