Laravel basics: what the framework gives you

What Laravel is

Laravel is a PHP framework: a set of ready classes and a fixed project layout for building web sites and JSON APIs. You write the code that is special to your project, and the framework does the repeated work: it reads the request, finds the code for the URL, talks to the database and sends the response.

It is open source, installed with Composer, and needs only PHP and a database to run. If you know plain PHP, classes and namespaces, you can start.

Main parts

Each part has its own lesson in the course.

How a request is handled

Every request enters through one file, public/index.php. Laravel starts, runs the middleware, and finds the route that matches the URL. The route calls a controller method. The controller reads or changes data through Eloquent models and returns a response: a Blade view for a browser or JSON for an API. The response goes back through the middleware to the visitor.

What a project looks like

The main folders of a new project:

laravel-app/ ├── app/ models, controllers, middleware ├── config/ settings ├── database/ migrations, seeders, factories ├── public/ index.php, the docroot ├── resources/ Blade views, CSS, JS ├── routes/ web.php and other route files ├── storage/ logs, cache, uploaded files ├── tests/ ├── .env settings of this machine └── artisan

When to choose Laravel

Laravel is a good choice for:

For one static page or a small script a framework is more than you need: plain PHP is enough.

The other large PHP framework on this site is Symfony.

Where to go next

Install the framework in lesson 2, Install Laravel, or see every lesson on the Laravel page.

Article author: Klavdiya Kondakova