Skip to content

Laravel

The PHP Framework for Web Artisans

  • Blade
    • Templating engine that allows using full PHP
  • Cashier
    • Subscription billing using Stripe or Paddle
  • Dusk
    • Selenium-based browser automation (testing)
  • Echo
    • Event broadcasting using WebSockets (for JavaScript clients)
  • Eloquent
  • Homestead
    • Pre-packaged Vagrant VM for development
  • Horizon
    • Dashboard and code-driven configuration for your Laravel powered Redis queues

  • Octane
    • Increase performance and concurrency with application servers
  • Pint
    • Opinionated PHP code style fixer

  • Queues
    • Process jobs using Redis, Amazon SQS, or even MySQL and Postgres.

  • Sanctum
    • Manage simple API keys/tokens
  • Sail
    • A light-weight command-line interface for interacting with Laravel’s default Docker development environment

  • Scout
    • Syncs ORM models/records with full-text search indexes in Algolia, Meilisearch, or MySQL/PostgreSQL
  • Socialite
    • OAuth authentication via Facebook, Twitter, LinkedIn, Google, GitHub, GitLab, and Bitbucket
  • Telescope
    • Debugging UI
  • Valet
    • nginx-based development environment for macOS
  • Nova
    • Administration panel for Laravel

  • Spark
    • Recurring billing using Stripe, Paddle, PayPal (via Paddle)
  • Envoyer
    • Zero-downtime deployment for all PHP applications
  • Forge
    • Provision and deploy unlimited PHP applications on DigitalOcean, Akamai, Linode, Vultr, Amazon, Hetzner and more.

  • Vapor
    • A serverless deployment platform for Laravel, powered by AWS

    • Learn Laravel Vapor YouTube playlist
  • Breeze
    • Lightweight starter kit scaffolding for new applications with Blade or Inertia.

  • Jetstream
    • Starter kit using Tailwind and either Livewire or Inertia scaffolding
  • Inertia
    • Create modern single-page React, Vue, and Svelte apps using classic server-side routing. Works with any backend — tuned for Laravel.

  • Livewire
    • Livewire is a full-stack framework for Laravel that makes building dynamic interfaces simple, without leaving the comfort of Laravel.

  • This example assumes Ubuntu 22.04.
  • Adjust the usernames everywhere (search for “claus” and “cconrad”).
#cloud-config
package_update: true
package_upgrade: true
packages:
- ssh-import-id
- nginx
- php8.1-fpm
- php-mysql
- php-cli
- unzip
- telnet
- php-mbstring
- php-xml
- php-bcmath
- php-curl
- mysql-server
power_state:
mode: reboot
runcmd:
- sed -i -e '/^\(#\|\)PasswordAuthentication/s/^.*$/PasswordAuthentication no/' /etc/ssh/sshd_config
- sed -i -e '/^\(#\|\)X11Forwarding/s/^.*$/X11Forwarding no/' /etc/ssh/sshd_config
- sed -i -e '/^\(#\|\)MaxAuthTries/s/^.*$/MaxAuthTries 2/' /etc/ssh/sshd_config
- sed -i -e '/^\(#\|\)AuthorizedKeysFile/s/^.*$/AuthorizedKeysFile .ssh\/authorized_keys/' /etc/ssh/sshd_config
- rm /var/www/html/*
- chown -R claus:claus /var/www/html
- curl -sS https://getcomposer.org/installer -o /root/composer-setup.php
- php /root/composer-setup.php --install-dir=/usr/local/bin --filename=composer
system_info:
apt_get_wrapper:
enabled: False
users:
- name: claus
groups: users, admin
sudo: ALL=(ALL) NOPASSWD:ALL
shell: /bin/bash
ssh_import_id:
- gh:cconrad
write_files:
- path: /etc/nginx/sites-enabled/default
content: |
server {
listen 80 default_server;
root /var/www/html;
index index.html index.htm index.php;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
}
}
  • If Laravel does not seem to use translation files from the ./lang directory, check if you have a ./resources/lang directory, and delete it.
\Illuminate\Support\Facades\DB::connection()->enableQueryLog();
// Run some queries...
$queries = \Illuminate\Support\Facades\DB::getQueryLog();

Changes to “Job” classes do not take effect

Section titled “Changes to “Job” classes do not take effect”
  • Make sure to restart the queue worker (e.g. Horizon) after each code change.

Laravel Tinker does not alias model automatically

Section titled “Laravel Tinker does not alias model automatically”
  • Run composer dump-autoload to regenerate the list of all known classes
  • The $model->unguard() method allows to temporarily remove protection from mass assignment on a model instance. Apparently this also allows updating the created_at property.

“A facade root has not been set.” in beforeAll of Pest test

Section titled ““A facade root has not been set.” in beforeAll of Pest test”
  • Laravel methods only work in beforeEach, not in beforeAll.