The essential news about content management systems and mobile technology. Powered by Perfect Publisher and XT Search for Algolia.
The News Site publishes posts to the following channels: Facebook, Instagram, Twitter, Telegram, Web Push, Tumblr, and Blogger.
FrankenPHP just hit a significant milestone this week, reaching a v1.0 release. A modern PHP application server written in Go, FrankenPHP gives you a production-grade PHP server with just one command.
It includes native support for Symphony, Laravel, WordPress, and more:
Is there support for FrakenPHP in Laravel Octane? Not yet, but there is an active pull request to Add support for FrankenPHP to Laravel Octane.
Which PHP modules are supported? I tried looking for a definitive list, but from what I gather most popular PHP extensions should work. The documentation confirms that OPcache and Debug are natively supported by FrankenPHP.
You can get started with FrankenPHP at frankenphp.dev, and browse the documentaion to learn about the worker mode, Docker images, and creating static binaries of your application.
If you want to experiment with your application, the easiest way to try it out is to run the following Docker command:
docker run -v $PWD:/app/public \
-p 80:80 -p 443:443 \
dunglas/frankenphp
For Laravel, you'll need to run the following Docker command (the FrankenPHP Laravel docs have complete setup instructions):
docker run -p 443:443 -v $PWD:/app dunglas/frankenphp
You can also run the frankenphp
binary in macOS and
Linux if you'd rather not use Docker.
The post FrankenPHP v1.0 is Here appeared first on Laravel News.
Join the Laravel Newsletter to get all the latest Laravel articles like this directly in your inbox.
Read more https://laravel-news.com/frankenphp
Dan Alatorre murders people for a living. Not literally, but literarily: His thrilling mystery novels have captivated audiences around the world, landing him on multiple bestseller lists.
Like so many authors of the internet age, Dan started his writing journey with a blog. Back then, his posts were focused more on the day-to-day happenings of his life, and they eventually provided the fodder for his first book: a silly autobiographical tale about a father and his daughter.
Dan has always had many different stories to tell. He published titles in a variety of genres, such as horror, romance, humor, and science fiction, before he tried his hand at murder mysteries. It didn’t take long for his unforgettable characters and unique storytelling to captivate audiences.
“It is great when some stranger you’ve never met picks up your book and reads it. You wrote words down, they read it, and it changed their life.”
For inspiration when writing his novels, Dan looks to what has piqued his interest throughout his life–1950s film noir classics, modern-day crime shows, and mystery authors like Agatha Christie–and then puts his unique spin on things. In his most popular series, Double Blind, he’s found an equation for success: two detectives, with an underlying current of romantic tension, working to solve a murder. Each case is its own self-contained story, so it not only works as part of the series, but it also makes a good standalone novel. “Good ideas were and are everywhere for an author, so I have about twenty additional story ideas for the characters,” he says. “As long as readers enjoy reading them, I’ll keep writing them.”
His creativity unlocked, Dan was able to concentrate on that all-important but oft-ignored aspect of any creative business: marketing. His website, danalatorre.com, was already his personal space on the web but it also gave his fans a VIP entrance to interact with him. With his Readers Club, Dan is able to go above and beyond simply promoting his books, building an active community of engaged readers. That sense of connection—with other murder-mystery fans as well as with him, the author—makes each new novel even more likely to be a success.
“It’s a great way to build that rapport with your fan base. If they’re interacting with their favorite author, they’re a fan for life.”
But don’t just take his word for it. If you’re an active (or aspiring) author, there are many other reasons to carve out a corner of the internet just for yourself and your fans.
Since writing is already something you do, an active blog can help provide insight to your audience about your writing process, upcoming events, story ideas, and so much more. It will position you as a valuable resource for readers and potential collaborators, leaving them eager to hear more from you.
Your website is a distillation of your personal brand, reflecting your unique literary style, voice, and identity. Choosing the right theme for your site—from colors, to fonts, to layout, and more—can help reinforce your work as an author. A good website builds trust, and it can help you stand out like a literary beacon in the vast sea of books.
In an age of online reviews and social media commentary, other voices can often shape the narrative. A personal website provides a platform for you to tell your own story, highlighting your work in the way that you want.
Ready to write your success story? Use coupon code wpsuccessda for 25% off annual plans. Visit WordPress.com/pricing or click below to get started:
Get 25% offRead more https://wordpress.com/blog/2023/12/07/dan-alatorre/
Laravel community member Aaron Francis shared an awesome video demonstrating how to Make self-healing URLs with Laravel. Without surprise, multiple packages in the Laravel ecosystem have already surfaced:
These packages have a similar goal: you can change your model's route slug at will or only partially match a URL and never have to worry about SEO indexing when the slug changes. Both packages work by adding a trait to a model (this example is taken from Luke's package), which handles identifying the model via route model binding:
use Lukeraymonddowning\SelfHealingUrls\Concerns\HasSelfHealingUrls;
class Post extends Model
{
use HasSelfHealingUrls;
// Optional custom model property (default is `slug`)
protected $slug = 'title';
}
Note: both packages have different implementations, so be sure to follow the respective README files to get started.
Luke's package also has the ability to customize the way a slug
is joined to a model identifier; you can create your own custom
IdentifierHandler
implementation. At the time of
writing, the package ships with a
HyphenIdentifierHandler
that looks like this:
namespace Lukeraymonddowning\SelfHealingUrls\IdentifierHandlers;
use Illuminate\Support\Str;
use Lukeraymonddowning\SelfHealingUrls\Contracts\IdentifierHandler;
class HyphenIdentifierHandler implements IdentifierHandler
{
public function joinToSlug(string $slug, string|int $identifier): string
{
return "{$slug}-{$identifier}";
}
public function separateFromSlug(string $value): string
{
return Str::afterLast($value, '-');
}
}
You can implement this interface to come up with your customized
handler if you want to use a different identifier than a slug and a
unique identifier separated by a hyphen (-
). I'd
encourage you to watch Aaron's video to see what's going on under
the hood in Laravel and try both implementations to see what you
like.
The post Self-healing URLs in Laravel appeared first on Laravel News.
Join the Laravel Newsletter to get all the latest Laravel articles like this directly in your inbox.
Read more https://laravel-news.com/self-healing-urls-in-laravel
Hello everyone, Caen here! I'm excited to share with you a
recent addition I made to the Laravel framework (PR #48845) that I believe will simplify your number
formatting needs. I've introduced a new Number
utility
class that provides several new helpers to format numbers, and it
should be available in the next Laravel release this week.
As another bonus: the helpers are locale-aware, so you can format numbers according to the current locale, either globally, or on a per-method basis!
In many applications, there's often a need to format numbers according to different requirements, such as displaying them as currency, percentages, or human-readable file sizes. Laravel didn't have a dedicated utility for this, so with the help of the community, I decided to create one. I've been working on this utility class for a a little while now, and am really excited that it was merged into the framework. Let's take a look at what it offers.
Number
ClassAll methods are part of the
Illuminate\Support\Number
class:
use Illuminate\Support\Number;
Using the format
method, we can format a number
according to the current locale.
Number::format(25) // 25
Number::format(100000) // 100,000
Number::format(123456789) // 123,456,789
We can also specify a custom locale to format the number according to that locale's rules.
Number::format(123456789, locale: 'en') // 123,456,789
Number::format(123456789, locale: 'de') // 123.456.789
Number::format(123456789, locale: 'sv') // 123 456 789
The formatPercentage
method formats a number as a
percentage according to the current locale.
Number::percentage(25) // 25%
Number::percentage((1/3) * 100, precision: 2) // 33.33%
Here's another fun method used to format various currencies with locale support. Perfect for your webshops!
Number::toCurrency(10) // $10.00
Number::toCurrency(25, currency: 'EUR') // €25.00
Number::toCurrency(5.49, currency: 'EUR', locale: 'de') // 5.49 €
Here is the toFileSize
method which actually is the
whole reason behind this utility class. I first submitted a PR to
add a File::bytesToHuman()
helper (PR #48827), which Taylor then suggested we add as part of a new
Number
class.
Number::toFileSize(1024); // 1 KB
Number::toFileSize(1600, precision: 2); // 1.56 KB
Number::toFileSize(1024 * 1024 * 1024 * 5); // 5 GB
Next up is also a quite fun one for when you want something that's more readable than precise. It converts numbers to a human-readable string.
Number::forHumans(1000) // 1 thousand
Number::forHumans(12345) // 12 thousand
Number::forHumans(12345, precision: 3) // 12.345 thousand
We can set the locale globally using the setLocale
method, for example in a service provider:
Number::setLocale('sv');
You can also use the withLocale
method which
executes the given callback using the specified locale and then
restores the original locale:
Number::withLocale('sv', function () {
return Number::format(123456789);
});
I hope this new addition makes your life a bit easier when dealing with number formatting in Laravel. Please free to check out the next Laravel release and incorporate this utility class into your projects. Happy coding!
Update 11/21/2023: The Numbers helper is now documented in the official Laravel helpers documentation.
The post Introducing the Laravel Number Helpers appeared first on Laravel News.
Join the Laravel Newsletter to get all the latest Laravel articles like this directly in your inbox.
Read more https://laravel-news.com/laravel-number-utility-class
The Laravel team released v10.35 with a Blade @use
directive, a number abbreviation helper, the ability to generate a
secret with artisan down
, and more. Here is a bit more
info about the new features introduced this week:
@use()
directiveSimon Hamp contributed a @use()
directive
to import a PHP class into a Blade template without using raw PHP
tags:
{{-- Before --}}
@php
use \App\Enums\WidgetStatusEnum as Status;
@endphp
{{-- After --}}
@use('App\Enums\WidgetStatusEnum', 'Status')
@use('App\Models\Bar')
{{ Status::Foo }}
{{ Bar::first() }}
Number::abbreviate()
method@jcsoriano contributed a
Number::abbreviate()
class to the newly added Number Class, which provides a human-readable
abbreviated number:
Number::abbreviate(1_000_000); // "1M"
Number::abbreviate(100_001); // "100K"
Number::abbreviate(100_100); // "100K"
Number::abbreviate(99_999); // "100K"
Number::abbreviate(99_499); // "99K"
--with-secret
option to the artisan
down
commandJacob Daniel Prunkl contributed a
--with-secret
option to the artisan down
command that will generate a secret phrase that can be used to
bypass maintenance mode so the user doesn't have to define one
themselves:
Conditionable
trait to the
AssertableJson
classKhalil Laleh contributed adding the
Conditionable
trait to the AssertableJson
class, to make it possible to assert based on a given
conditional:
// Before
$response->assertJson(function (AssertableJson $json) use ($condition) {
$json->has('data');
if ($condition) {
$json->has('meta');
}
$json->etc();
});
// After
$response
->assertJson(fn (AssertableJson $json) => $json->has('data'))
->when($condition, fn (AssertableJson $json) => $json->has('meta'))
// ...
;
You can see the complete list of new features and updates below and the diff between 10.34.0 and 10.35.0 on GitHub. The following release notes are directly from the changelog:
Conditionable
trait to
AssertableJson
by @khalilst in
https://github.com/laravel/framework/pull/49172--with-secret
option to Artisan
down
command. by @jj15asmr in
https://github.com/laravel/framework/pull/49171Number::summarize
by
@jcsoriano in https://github.com/laravel/framework/pull/49197The post Laravel 10.35 Released appeared first on Laravel News.
Join the Laravel Newsletter to get all the latest Laravel articles like this directly in your inbox.
Read more https://laravel-news.com/laravel-10-35-0