AITeky Learn

AiTeky Original Interactive Learning & Practice Intermediate

PHP and Laravel: queries per page, mass assignment and jobs that run twice

Understand why a Laravel page can run hundreds of database queries without a single error, why letting a form set any field is dangerous, and why a queued job must be safe to run twice.

PHP powers a large share of the web, and Laravel is its most popular framework. It makes common work short and pleasant, and that is exactly why three problems are easy to create without noticing: too many database queries on one page, forms that can change fields they should not, and background jobs that run more than once.

This course models those ideas with small Python programs you can run in your browser. Python stands in for PHP: the code is not PHP, but the behaviour and the numbers show how the framework works. Check the Laravel documentation for exact syntax (for example with(), $fillable and ShouldBeUnique). All numbers are made up.

  • Learn lessons explain one idea at a time and let you run it.
  • Industry ready lessons decide and justify, and end with interview questions.

No PHP experience is assumed. Basic Python helps.

Locked. Sign up free

Learn

Understand each idea with everyday examples. No coding background needed.

  1. 00 25 min 🔒 AiTeky Pass Start here: from request to page Follow a web request from the address a visitor types to the page that comes back, and see the three parts of a Laravel app: routes, controllers and the data behind them.
  2. 01 30 min Free sample 🔒 AiTeky Pass One query or one hundred Model a list page that loads related data one row at a time (the N+1 problem), count the database queries, and see how loading the related rows in one extra query keeps the count flat as the page grows.
  3. 02 30 min 🔒 AiTeky Pass Who may set which field Model a form that saves whatever fields the browser sends (mass assignment), see how a user can promote themselves to admin by adding one extra field, and fix it with an allow-list of fields.

Industry ready

Real problems from real jobs, and the questions interviewers ask about them.

  1. 03 35 min 🔒 AiTeky Pass On the job: the customer charged twice Some customers are charged twice after a queue worker is restarted. Model a queue that delivers a job again when the worker does not confirm it, count the double charges under four fixes (fewer retries, longer timeout, a lock, an idempotency check), choose, and write the incident note.

We use essential cookies to run the site. With your permission we also set one anonymous ID to count unique visitors, and analytics cookies to see which pages help learners. Cookie notice

Join AiTeky Learn. It's free.

Create a free account to track your progress, save items for later and get study suggestions.

Sign up free Log in