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.
The Cloudflare Cache package for Laravel provides
cacheable routes, allowing you to serve millions of requests for
static pages efficiently. You can define a group of cacheable
routes with the Laravel router, including tags. This package makes
it easy to start caching with Cloudflare using the
Route::cache()
method:
Route::cache(tags: ['tag1', 'tag2'], ttl: 600)->group(function () {
Route::get('/content_with_tags', function () {
return 'content';
});
});
Route::cache(tags: ['staticPages'])->group(function () {
//
});
This package gives you APIs to purge all content, specific URLs, prefixes/tagged URLs (enterprise), and more. As an example, let's say you want to cache articles (Posts) with Cloudflare and purge the cache whenever the article is updated:
<?php
namespace App\Http\Controllers;
use App\Http\Requests\UpdatePostRequest;
use App\Models\Post;
use Yediyuz\CloudflareCache\Facades\CloudflareCache;
class PostController extends Controller
{
public function update(Post $post, UpdatePostRequest $request)
{
$post->update($request->validated());
CloudflareCache::purgeByUrls([
route('post.show', $post->id)
]);
return back()->with('message', 'Post updated and url cache purged');
}
You can learn more about this package, get full installation instructions, and view the source code on GitHub.
The post Cache Routes with Cloudflare 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/laravel-cloudflare-cache
In this video, Ben Holmen teaches us how to manage timezones in your Laravel apps. Some of the highlights include:
Here are the code samples used in the video:
Carbon::macro('inApplicationTimezone', function() {
return $this->tz(config('app.timezone_display'));
});
Carbon::macro('inUserTimezone', function() {
return $this->tz(auth()->user()?->timezone ?? config('app.timezone_display'));
});
Give it a watch and learn all about Timezones and how to easily manage them!
The post Learn how to manage timezones in your Laravel Apps 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-timezones
The Can I PHP? Raycast extension by Diana Scharf lets you check if a certain function or method is available in different versions of PHP. You can see which versions are supported and the deprecation status at a glance:
If you hit Enter, you get a helpful details page from the caniphp.com project. The Can I PHP API is like caniuse.com, but for PHP. The alternative to this extension is manually looking up the PHP documentation and finding when something was introduced; for example, here's the uft8_decode documentation:
To get started with this extension, you can search the store for "Can I PHP":
You can also check out the extension's Raycast page in the Raycast store. The source code is also available on GitHub in the Racast extensions repository.
The post "Can I PHP?" Raycast Extension 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/can-i-php-raycast
WordPress block-based themes allow you to build and customize your website visually, removing the need for code-based tailoring. Fully integrated with the Site Editor, block themes give an unprecedented level of visual control over the layout and style of your site.
In this “Build and Beyond” video, Jamie Marsland walks you through everything you need to know about editing, customizing, and designing every element of your WordPress site using blocks in just 250 seconds. You’ll also get a few sneak peeks of some theme-related features coming in WordPress 6.5 (which will be released March 26, 2024!).
Ready to build on WordPress.com? Start a free trial today:
Start free trialRead more https://wordpress.com/blog/2024/03/21/wordpress-block-themes/
Laravel added a new Context
service to define
contextual data to the current request. Context data is included in
all log entries for that request, and queued jobs will also retain
that same data. Using contextual data allows you to easily trace
back code execution for a given request and any distributed flows
in your application:
// In a middleware...
Context::add('hostname', gethostname());
Context::add('trace_id', (string) Str::uuid());
// In a controller...
Log::info('Retrieving commit messages for repository [{repository}].', [
'repository' => $repo,
]);
Http::get('https://github.com/...');
/*
Log entry example:
[2024-01-19 04:20:06] production.INFO: Retrieving commit messages for repository [laravel/framework]. {"repository":"laravel/framework"} {"hostname":"prod-web-1","trace_id":"a158c456-d277-4214-badd-0f4c8e84df79"}
*/
Contextual data also supports concepts like stacks, where you can push data to the same context, effectively appending data:
Event::listen(function (JobQueued $event) {
Context::push('queued_job_history', "Job queued: {$event->job->displayName()}");
});
Context::get('queued_job_history');
// [
// "Job queued: App\Jobs\MyFirstJob",
// "Job queued: App\Jobs\MySecondJob",
// "Job queued: App\Jobs\MyThirdJob",
// ]
If you'd like to learn more about this feature, check out the Pull Request description. Hat tip to Tim MacDonald, who created this feature for the framework!
The post Introducing the Context Facade 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/laravel-context-facade