Laravel News
397 FOLLOWERS
Laravel News is the official blog of Laravel. Every day bringing you the latest news, tutorials, and packages for the framework.
Laravel News
9h ago
The Property Hooks RFC passed a significant milestone, getting an overwhelmingly positive 34 "yes" votes and only 1 "no" vote. That's well above the required 2/3 majority required to pass.
What are property hooks in PHP?
Here's the proposal summary from the RFC:
Developers often use methods to wrap and guard access to object properties. There are several highly common patterns for such logic, which in practice may be verbose to implement repeatedly. Alternatively, developers may use __get and __set to intercept reads and writes generically, but that is a sledge-hammer approach that intercept ..read more
Laravel News
1d ago
This week, the Laravel team released v11.4, with reversible form Prompts, a new Exceptions facade, Enum support in the Collection::mapInto() method, and more.
Introduce the Exceptions Facade
Nuno Maduro contributed the Exceptions facade:
The Exceptions facade provides a consistent way to test exceptions in Laravel applications. Here is the list of methods that the Exceptions facade provides:
assertReported
assertReportedCount
assertNotReported
assertNothingReported
throwOnReport
throwFirstReported
Here's an example from the pull request description illustrating the Exceptions::fake() meth ..read more
Laravel News
2d ago
It's 2024 and I'm calling it - Server-Side Rendering has officially made a comeback:
in Laravel, where Livewire now has 46.000 installs per day
in Ruby on Rails with Hotwire
in Phoenix with Liveview
in web dev in general with HTMX
Now that "the old has become the new"... maybe it's time to re-visit another practice we've adopted from the Javascript ecosystem. Maybe it's time to... drop the build step? Crazy, I know! But there's been a lot of talk about no-build Laravel setups in my bubble. And there's one place where people invariably get stuck - "If we drop NPM, what do we do about JS depe ..read more
Laravel News
4d ago
The Random package by Stephen Rees-Carter, generates cryptographically secure random values in a range of different formats through a simple helper package for PHP. Here is why this package was created:
Something I commonly encounter during my security audits (especially on older codebases) is insecure randomness, usually in places where security is required. It’s usually using some form of rand(), often injected inside md5() to generate a random hash, combined with str_shuffle() to generate new passwords, or used to make an One-Time Password (OTP) with rand(100_000, 999_999).
The problem ..read more
Laravel News
1w ago
PhpStorm has good automatic formatting of PHP files based on standards like PSR-2, PSR-12, Symfony, Laravel, etc.; however, there have not been a lot of options for consistently formatting blade files in PhpStorm until recently. There are whispers of Blade formatting coming to Laravel Pint, but another interesting option is using the JavaScript's Prettier code formatting tool with the prettier-plugin-blade plugin.
Matt Stauffer's article How to set up Prettier On a Laravel App, Linting Tailwind Class Order and More is an excellent primer to formatting Tailwind and Blade using Prettier.
Here's ..read more
Laravel News
1w ago
PhpStorm, the PHP IDE by JetBrains, released version 2024.1 this week with a brand new terminal, local AI code completion, Pest improvements, and more.
The new terminal in PhpStorm 2024.1
Here's the list of highlights from this release:
New terminal
Full line code completion with local AI
Sticky lines pinned to the top in the editor
Pest Improvements
PHPUnit 11.0 support
Support for Symfony’s AssetMapper
Improvements to dd(), var_dump(), and Symfony's var-dumper
Check for vulnerable packages in composer.json
Frontend updates
Component usages for Vue, Svelte, and Astro
Language services widg ..read more
Laravel News
1w ago
This week, the Laravel team released v11.3, which includes multi-line text in Laravel Prompts, a Session:hasAny() method, a Context::pull() method, and more.
Multi-line Text Prompts
Joe Tannenbaum contributed a textarea function to Laravel prompts that accepts multi-line text from a user:
Multi-line text input in Laravel Prompts
The textarea() function includes an optional validation argument as well as a required argument to make sure the textarea is filled out:
use function Laravel\Prompts\textarea;
$story = textarea(
label: 'Tell me a story.',
placeholder: 'This is a story about ..read more
Laravel News
1w ago
The Bartender package for Laravel is an opinionated way to authenticate users using Laravel Socialite. Bartender serves you a controller, routes, and a default implementation for handling authentication with Laravel Socialite providers. Almost everything in Bartender can be customized.
Using the configuration conventions, you can enable social logins by defining the routes and configuring the providers you're app will support:
// routes/web.php
use DirectoryTree\Bartender\Facades\Bartender;
Bartender::routes();
// config/services.php
return [
// ...
'google' => ..read more
Laravel News
2w ago
This PDF Optimizer package for PHP and Laravel applications for effortless optimization and compression of PDF files. PDF Optimizer utilizes Ghostscript to significantly reduce PDF file sizes. The PDF Optimizer package can be used in any PHP project but also offers Laravel-specific APIs that streamline working with PDF file optimization:
use Mostafaznv\PdfOptimizer\Laravel\Facade\PdfOptimizer;
use Mostafaznv\PdfOptimizer\Enums\ColorConversionStrategy;
use Mostafaznv\PdfOptimizer\Enums\PdfSettings;
$result = PdfOptimizer::fromDisk('local')
->open('input-1.pdf')
->toDisk('s3 ..read more
Laravel News
2w ago
Laravel Harbor is a CLI tool that allows you to quickly create on-demand preview environments for your app on Laravel Forge. Using this CLI, you can use GitHub actions to automatically deploy your branches when pull requests are created and tear down the deployment from your server when the pull request is merged. Here's an example of a provisioning workflow using GitHub actions (taken from the documentation):
name: preview-provision
on:
pull_request:
types: [opened, edited, reopened, ready_for_review]
jobs:
harbor-provision:
if: |
github.event.pull_request.draft == false ..read more