Série Programming One Volume 2 Kindle

PHP One

Speeding Up with Laravel

The Casa Amarela Library API, from raw HTTP to deployment: REST, a forty-line framework written by hand, Laravel, Eloquent, validation, API Resources, standardized errors, service container, Sanctum, Policies, queues, cache, tests and documentation — plus life after deployment: uploads, email, notifications and production queues.

R$ 9,99 R$ 29,99 Promoção

Atenção: o idioma desta edição é inglês.

31capítulos
8partes
1projeto do início ao fim
Capa de PHP One — Volume 2: Speeding Up with Laravel, de Thiago Nogueira English Edition
PHP 8LaravelEloquentSanctumPoliciesQueuesPestOpenAPI
código do livro

Menos teoria vazia.
Mais código que funciona.

Nada de exemplo solto com foo e bar. Todo trecho pertence ao mesmo projeto, que cresce capítulo a capítulo — e os erros aparecem como aparecem na sua tela, para serem lidos linha por linha.

routes/api.php
<?phpuse App\Http\Controllers\BookController;use Illuminate\Support\Facades\Route;Route::apiResource('books', BookController::class);
terminal
php artisan route:list --path=apiGET|HEAD  api/books ...... books.index › BookController@indexphp artisan testPASS  LoanTest
o projeto

Um sistema só, do primeiro arquivo ao deploy

README.md

Continues the Casa Amarela Library system from volume 1. Now it becomes an API consumed by Kauã's app, with authentication, permissions, queues and a deployment that does not require an overnight watch.

From the first HTTP request to a Laravel API in production.

  • A forty-line framework, written by hand, before Laravel
  • Eloquent built on the SQL you already know how to write
  • An API with validation, authorization, queues, tests and documentation
  • Standardized errors, measured caching and a deployment without firefighting
sumário

31 capítulos em 8 partes

Abra uma parte para ver os capítulos — e a frase que abre cada um.

parte 01 The web beneath the frameworkHTTP, REST and a forty-line framework written by hand. After this stretch, no part of Laravel will look like magic — it will look like work someone already did. 4 cap.
  1. 01
    What HTTP isThe app sent the data. The server received the data. And $_POST was empty.
  2. 02
    What a REST API isMr. Juvenal wants a button that renews everything. The hard question is not how to do it — it is what happens when someone presses it twice.
  3. 03
    A forty-line frameworkAfter writing the router, the intern's question was the best one in the project: why not just use this one?
  4. 04
    What Laravel isThe answer to the intern's question has two parts: what the framework does for you, and what it decides without asking.
parte 02 Inside LaravelStructure, configuration, routes, controllers and responses. The framework arriving after the problem, which is the only order in which it makes sense. 5 cap.
  1. 05
    The first projectMr. Juvenal saw the welcome screen, read the framework's name in big letters and asked whether he could start registering the books.
  2. 06
    Configuration, environment and ArtisanFines started coming out as zero in production, and on no other machine. The cause was an optimization command run during deploy.
  3. 07
    Routes and controllersThe System's index had 137 lines, and each line was a file name. Nobody had ever read that index all the way through.
  4. 08
    Requests and responsesThe intern uploaded a book cover called ../test.php. The System stored it, and the server executed it.
  5. 09
    Blade, when the screen is still the answerVera doesn't want an app. She wants a search field and a button, like the one in the Sistema, which worked.
parte 03 Eloquent on top of the SQL you already knowThe ORM comes after SQL. Every method has a matching query you can write by hand — and that is what separates using Eloquent from depending on it. 3 cap.
  1. 10
    Migrations, seeders and factoriesEleven forty on a Thursday. The terminal wrote Dropping all tables and he read the database address on the line above.
  2. 11
    EloquentThe reader sign-up accepted a field the form didn't have. Whoever found it became head librarian in nine seconds.
  3. 12
    RelationshipsThe catalog listing took four seconds. The log showed 143 queries to display 47 books.
parte 04 The real APIWhat separates a textbook CRUD from an API someone else consumes: validation, output format, pagination, filters and honest errors. 5 cap.
  1. 13
    The complete CRUDSeu Juvenal asked whether that wasn't just a CRUD. The answer had eleven items and was in the intern's notebook.
  2. 14
    Validation and Form RequestsThe same book was in the collection three times. The ISBN was the same in all three — except for the hyphens.
  3. 15
    API ResourcesThe column was created for the team to note down what it wouldn't say in front of the reader. For eleven days, the reader read it.
  4. 16
    Pagination, filters and searchSearching for "acafrao" didn't find "Açafrão". Half the collection had been registered on keyboards from a public tender, with no cedilla.
  5. 17
    Standardized errorsThe reader called saying there was an error. The log had 4,200 lines and no clue which one was his.
parte 05 Architecture and securityWhere the business rule lives, how many layers your project really needs, and the two questions every request answers: who are you and what are you allowed to do. 5 cap.
  1. 18
    Service Container and dependency injectionDedé opened the twenty-line container next to Laravel's. The intern recognized the reflection before he pointed at it.
  2. 19
    Services: where the business rule livesVera read the method aloud and corrected a rule the team had misunderstood for four months. It took eighteen seconds.
  3. 20
    MiddlewareThe logging middleware recorded the whole body of every request. For three months, that included the password field.
  4. 21
    Authentication with SanctumThe Sistema stored passwords as MD5, unsalted. Over lunch, on a developer's machine, sixty percent fell in four minutes.
  5. 22
    Authorization: Gates and PoliciesThe reader called, excited: he had discovered that, by changing a number in the address, he could see everyone's books.
parte 06 After the responseEvents, queues, caching and logs. The work that does not fit inside the request — and what you will want to have measured when something breaks. 2 cap.
  1. 23
    Events, jobs and queuesThe return reminder was sent 1,400 times to the same person. The job wasn't idempotent, and the worker restarted halfway through.
  2. 24
    Cache, logs and what gets measuredThe catalog page got fast and started showing as available a book that was on loan. For six hours, which was the cache's lifetime.
parte 07 Prove it and ship itTests that say what they are trying to prove, documentation that is born from the code, and the road to deploy day without a night on call. 4 cap.
  1. 25
    Tests: what we are trying to proveThe fine for early returns had been fixed in October. In February, it came back by another path. There was a fix; there was no test.
  2. 26
    Feature tests, HTTP and the databaseThe pipeline stayed red for three days on a test that passed on every local machine. An ORDER BY was missing — in the test and in the code.
  3. 27
    API documentationIntegrating the app took three weeks. The API's only documentation was one sentence: "ask Dedé".
  4. 28
    Git, CI and deploy dayOn the 31st of March, at seven in the morning, the folded paper with the FTP password left the project folder for the last time.
parte 08 The system in productionThe day after the deploy. The requests that only show up when real people use the system: phone photos, e-mail signed by the wrong sender and a queue that grows faster than it drains. 3 cap.
  1. 29
    File uploadsVera photographed three hundred covers with her new phone. Half didn't upload. The other half uploaded lying on their side.
  2. 30
    Mail and notificationsCasa Amarela's first e-mail was signed by someone called Laravel, from hello@example.com. Dona Marlene printed it and brought it to the counter as proof of the scam.
  3. 31
    Queues in practiceThe nine o'clock notice arrived at three in the afternoon. Ahead of it, in the same queue, were Seu Juvenal's two hundred thousand books.
comece pelo

PHP One — Volume 1

PHP Fundamentals — Modern PHP from zero, before any framework.

Ver volume 1 →
avaliações verificadas

O que leitores dizem sobre PHP One — Volume 2

Carregando avaliações deste livro…

Ver todas as avaliações deste livro →
combo

Este livro também entra em um combo

O combo reúne livros já publicados e sai num único pagamento.

git commit -m "primeiro capítulo"

PHP One

From the first HTTP request to a Laravel API in production. O projeto começa a rodar no primeiro capítulo — e não para mais.

Atenção: o idioma desta edição é inglês.