Laravel: What it is and where to Learn

The ultimate guide to know where to start, if you haven’t yet.

Italo Baeza Cabrera
ITNEXT

--

If you’re reading this, you probably came here looking for how to make your own web application. Just go on read this quick introduction so I can point you to the next thing you should do. Just keep reading, no worries.

So, what’s is Laravel?

Laravel is a PHP framework. In layman’s terms, instead of programming everything from the first line to the last, Laravel offers something like a “skeleton” of a web application.

How you make a person from that skeleton is your job. Laravel includes and eases most of the common tasks of a web application from the start of the HTTP Request to the end of your logic. For example:

  • You need a Sign in? Authentication comes out of the box.
  • Need to use Cookies and Sessions? Cookie and Session management also out of the box.
  • Simple syntax to write your HTML views? Blade templating engine can help you out.
  • A simple way to talk to the database? No more raw SQL calls! Eloquent will allow you to do that in a flexible way and protect you from SQL injection.

All that and many more of these tools can be coded for your application using clear and understandable syntax, like this:

$playlists = $request->user()->playlists()->all()

That piece of code will get all the playlists of the authenticated user, without the need of telling what user, what SQL syntax, and no unrecognizable methods.

Still don’t get the concept? Imagine you have to create your house. Instead of going to the forest, cut wood and make a door from it, you can go to your closest hardware store and buy an already-made door you like. Even change the door knob!

How can I learn?

I’ve tried with a lot of small projects, and personally I think the best way to learn is to make To-Do list: it’s small, simple, very straightforward, and it allows you to learn the basic inner-workings of the framework before bombarding you with other concepts.

You can also do more daunting things like a blog, an image gallery, a portfolio, etc. I recommend anything but small and simple so you can understand without having to write walls of code. There are thousand of tutorials for these projects if you need somebody holding your hand.

An example of Visual Studio Code being intelligent with code (from their blog)

A very common recommendation is to use an IDE for PHP development, as it will help you code quicker, guess less, and have a lot of tools ready to be used, like code completion — you will get suggestions while you’re typing something automatically or manually — and warnings if you type something wrong.

PHPStorm and Sublime Text are both paid (with a free beta and trial versions, respectively) but very useful and clear. Eclipse, Atom, and Visual Studio Code are free, and the latter has a Laracast video to make it your favorite IDE for PHP if you’re tight on the budget but not on time.

Pssst! While you’re it, I recommend you to pick a nice dark color theme for your IDE so you don’t burn your eyes.

Where can I learn?

You may want to start with Learn Laravel from scratch, the official course for learning Laravel. Sometimes the series is one version behind, but the basics are the same. If that’s the case, it should be complemented with the latest What’s new in Laravel.

If you liked Laracast, and want to learn other related things like Testing, Payments, and other topics, don’t be shy and get a subscription if it’s helpful for you.

Of course I won’t stop you from checking Udemy, Lynda, and many others sites that offer Laravel courses, even Youtube. Just be sure to check those up-to-date, since recent versions usually have more goodies to make your life simpler.

Is there a manual or something?

Of course! The official documentation is right here. It covers almost everything with detail, from installation to the end of the application lifecycle, leaving some advanced things ready to dive in by the advanced developers, like the Contracts, Service Container, Package development, etc. Everything is explained clearly, so you don’t have to be a PHP expert to understand.

A brief glimpse of the official documentation, the Routing section. Yes, I’m using Dark Reader.

My humble recommendation is to read at least the titles, so you can have a clear glance of the framework capabilities. It’s very frustrating when you start creating a feature from scratch without knowing Laravel already does that for you, and sometimes much better that you would expect (specially when it comes to error handling).

I don’t know PHP, or programming at all. What I can do?

It’s imperative to know some programming basics. PHP itself it’s not a difficult language to learn, it protects you from many things (like memory management), and it offers flexibility in how to do things.

Excuse me for the caps lock is cruise control for cool, but I have to remark this:

IF YOU SUCK AT PROBLEM SOLVING, OR DEPEND OF COPY & PASTING SOLUTIONS FROM THE WEB, PROGRAMMING MAY NOT BE FOR YOU… but you can try!

Okay, sorry about that. Everybody started at the bottom. And talking about starting something, The PHP Practitioner is a good and free resource to learn from zero.

Of course there are a lot of tutorials and courses spreaded all over the Internet, both free and paid, that can aid you in understanding programming in general, and PHP among other languages. Once you grasp the basic concepts, you can come back here.

Hey! I’m not a total noob! … but still

In case you know some PHP, then PHP The Right Way is practically THE MANUAL. Keep it close since it will help you understand the best practices to use PHP as you should and not to die trying.

If you have more experience, but your code quickly turns into a spaghetti, you may want to take a look into the PHP Design Patterns. These are strategies to build up your code and keep it understandable., while you stick to DRY and SOLID.

What is that “Vue” thing I read sometimes?

Vue.js is a JavaScript framework for the frontend. It’s very easy to use, and enables better interaction and reactivity, but detaching the frontend from the backend. Think about Single Page Applications and AJAX.

If you’re new to Laravel, you should stick to doing your application without any JavaScript unless ultimately necessary. And if you need it, use plain (or vanilla) JavaScript instead of jQuery, React, Vue or others frameworks. This will allow you to have a better grasp of the backend.

Once you understand Laravel, frontend frameworks like Vue.js can become your next big ally to keep your site snappy and modern.

I have a great idea for my next project! Can I do it in Laravel?

It’s better to tell what the framework doesn’t allow you to do: a native Mobile App, or Desktop software.

Laravel excels at being a web application, or a tiny web API, bound to HTTP Requests and scheduled jobs.

For the API side of things, were you need something fast, Lumen is like the bones of Laravel without much of the overhead of additional logics. It’s recommended to use only when you fully understand how Laravel works and you can do most of the work by yourself.

If you need an interface and management application for an already existing system, like for showing statistics of your Email Server, or a dashboard for your thermostat, it may work as long that system offers an API to communicate with Laravel. The HTTP Protocol is easy to manage thanks to the popular GuzzleHTTP package, but if you have another (like RPC, SMTP, FTP, etc), you may want to integrate another Composer package made by the community into Laravel, or even a PHP extension.

Again, Laravel it’s not a swiss-army knife, it’s a web application framework. If you are looking to make a critical business decision you may want to explore more languages options like Node.js, C++, C#, Go, Python, among others, for your particular project.

I see some “Composer” packages. What are those?

Composer is a package management system for PHP. Composer packages are like self-contained tools that the community and companies write to enable or extend PHP projects. Even Laravel is itself a Composer package!

For example, Laravel includes on his manifest the Carbon package, which is downloaded automatically as a dependency. Carbon allows you to manipulate time in a fluent way, like using today()->addHours(10) to get today at 10:00 AM, instead of coding time related functions from scratch. Some packages may depend on one or more packages, though, but the principle is the same.

You can also add other Composer packages yourself if you need some functionality that is already coded and you don’t want to spend the next years doing it from zero. Laravel has official packages too, available in the Github repository.

How can I “download” or “install” Laravel so I can start coding?

Check the Laravel official documentation, or the The PHP Practitioner. Everything you need is there, from the get-go to the last pieces of code you may need.

You should also install PHP in your machine, and Composer after that. Happy coding!

--

--

Graphic Designer graduate. Full Stack Web Developer. Retired Tech & Gaming Editor. https://italobc.com