Carbon is macroable in Laravel 5.5
Just a little reminder that Carbon is macroable in #Laravel 5.5 pic.twitter.com/6l7F883c7N
— Freek Van der Herten (@freekmurze) October 22, 2017
Read more [twitter.com]
Posts tagged with php
Just a little reminder that Carbon is macroable in #Laravel 5.5 pic.twitter.com/6l7F883c7N
— Freek Van der Herten (@freekmurze) October 22, 2017
Read more [twitter.com]
Clockwork is Laravel package, made by itsgoingd, that can collect a lot of helpful info such as queries executed, views loaded, route used, ... Unlike the popular laravel-debugbar package, Clockwork will not inject extra stuff into the html itself. All collected info is displayed in the developer tools of your browser (you'll need to install an extension first).
Join 9,500+ smart developers
Get my monthly newsletter with what I learn from running Spatie, building Oh Dear, and maintaining 300+ open source packages. Practical takes on Laravel, PHP, and AI that you can actually use.
No spam. Unsubscribe anytime. You can also follow me on X.
"As a Laravel developer, this is the one newsletter I most look forward to. Freek has a talent for distilling packages or techniques down to something immediately useful - one tip can save you hours and even weeks. It's concise and practical and highly relevant."
Most of the sites we build for our clients contain some sort of contact form. For those client such forms are potentially critical to their business. Imagine for instance a real estate firm that generates leads with such forms. In most cases we will store the submitted values in the db and mail them…
To convert html to a pdf or an image using wkhtmltopdf and wkhtmltoimage tends to be the popular option. Unfortunately those tools contain an outdated browser engine to do their thing, so you can't use any newish css syntax. A while ago Google added a headless mode to Chrome. They've also released a…
Chris Fidao has created an easy to handle, well documented, Docker dev environment for Laravel projects. It's an excellent starting point if you want to have a taste of what Docker can do.
For the introductory newsletter:
I like Vessel the best for the following reasons: 1. It's installed per-project instead of globally. This lets me customize it per project if need be. 2. Docker lets me change out versions of software such as Nginx, MySQL, Redis, and others very easily. (I've often needed to use an older MySQL version at work) 3. Docker lets me add extra software (perhaps Beanstalkd for queues, or PgSQL for database) really easily 4. Docker containers are more like processes than VMs. They generally only use what resources they need (with some caveats, but even with those, they're lighter than Vagrant virtual machines) 5. I can fill up my workstation with one technology (Docker!) instead of many (PHP, Redis, MySQL, etc) with all their configuration files and data strewn about all over my file system 6. You can expand on your dev workflow to build up to a production workflow using all the same technology (Docker!) - You can check out Shipping Docker for my full course on bringing Docker from dev into production.
Need to mock a specific method in a facade, leaving the remainder free to respond to calls normally? It's possible with "Partial Mocks". pic.twitter.com/VgVMdnBDid
— Raul (@rcubitto) October 4, 2017
Read more [twitter.com]
In the project I'm currently working on I had to integrate Stripe webhooks. Stripe has great documentation on how to handle webhooks, but it still took a fair amount of time to get the integration just right. My solution for handling webhooks is pretty generic and reusable by others. I decided to…
⚡️. @laravelphp rescue() helper : Catch a potential exception and return a default value #laravel 5.5.3 pic.twitter.com/Y8bRlx1gUc
— Jeff (@Jeffer_8a) September 8, 2017
Read more [twitter.com]
Addy Osmani, a Google Chrome engineer, recently published a e-book on image optimization. You can read it in it's entirety here: https://images.guide/
Images take up massive amounts of internet bandwidth because they often have large file sizes. According to the HTTP Archive, 60% of the data transferred to fetch a web page is images composed of JPEGs, PNGs and GIFs. As of July 2017, images accounted for 1.7MB of the content loaded for the 3.0MB average site.Per Tammy Everts, adding images to a page or making existing images larger have been proven to increase conversion rates. It's unlikely that images will go away and so investing in an efficient compression strategy to minimize bloat becomes important.
If you need to optimize images in your PHP application take a look at our image optimization package. If you're a Laravel user you'll be happy to know that there's also a Laravel version of the optimizer. Our Laravel Medialibrary also comes with built-in support for optimizing images.
Povilas Korop, creator of Laravel Daily and Quick Admin Panel, wrote an extensive guide on how to integrate Stripe into a Laravel application.
Stripe is one of the most popular payment merchants for web, but information about Laravel integration is pretty fragmented, so I decided to write a really long tutorial about this topic.We will cover:
- General logic how Stripe works
- Simple one-time payment integration
- Testing and production environment setup
- Saving transaction data for future reference
- Recurring payments with Laravel Cashier
- Getting invoices data and PDF download
https://quickadminpanel.com/blog/stripe-payments-in-laravel-the-ultimate-guide/
On his blog Frank De Jonge, member of the PHP League and creator of Flysystem, explains a cool pragmatic solution how to ensure queued processes for the same user complete in the right order.
The use of multiple workers allows for much higher throughput, but it also allows for race conditions during processing. When messages for the same user are sent to different workers, handling order can no longer be guaranteed. Therefore we have failed to fulfil our business rule.If we were able to ensure every message from the same user were sent to the same worker, the worker could ensure those messages are handled in order while the system as a whole would still benefit from the degree of parallelism. But how do we make this happen?
https://blog.frankdejonge.nl/parallelise-synchronous-business-processes/
The awesome Roave team has recently released v2 of their BetterReflection package. It can do anything PHP's native reflection API can, but without actually autoloading the code.
The operational concept is quite simple, really:
- We scan your codebase for files matching the one containing your class. This is fully configurable, but by default we use some ugly autoloader hacks to find the file without wasting disk I/O.
- We feed your PHP file to PHP-Parser
- We analyse the produced AST and wrap it in a matching Roave\BetterReflection\Reflection* class instance, ready for you to consume it.
Read all about it on Marco Pivetta's blog: https://ocramius.github.io/blog/roave-better-reflection-v2.0/
Every time our team releases a package I have the habit of writing an introductory blogpost. But after the initial release most pages gain more features through PRs by the community and ourselves. Mostly these new feature go unnoticed. That's why I plan on regularly writings posts on noteworthy…
JMac, the creator of Laravel Shift, shared how he can very easily spin up a new job on his service by sending a simple SMS message.
In the end, all I need is a quick way to run a Shift on the go. Looking back on almost two years of support, I often have the Shift number readily available. Creating the job and adding it to the queue is at most two lines of code. So the steps are not the pain point.The pain point is connecting to the server. Unless I want to carry my laptop around, I can’t connect to the server to run the Shift. (I actually have taken my laptop with me during peak times.)
What do I carry around with me all the time? My phone. I’m already reviewing the support emails from my phone. Wouldn’t it be great when I need to run a Shift manually to just reply or send a text.
https://jason.pureconcepts.net/2017/09/nexmo-sms-admin-laravel/
Jens Segers, developer at Teamleader and author of the popular Optimus and laravel-mongodb packages, wrote about an alternative to controllers.
Let me introduce you to request handlers. The concept is very simple, yet very unknown to a lot of PHP developers. A request handler is basically a controller, but limited to one single action. This concept is very similar to the Action-Domain-Responder pattern which was proposed by Paul M. Jones, an alternative for the MVC pattern that focuses on a more clear request to response flow for web applications.
https://jenssegers.com/85/goodbye-controllers-hello-request-handlers
We recently released our newest package called macroable. It contains a trait that, when applied to class, can dynamically add methods to that class. This trait is basically a stand alone version of the macroable trait in Laravel. In this post I'd like to show you how you can use it, how it works…
? Another newly documented Laravel 5.5 feature: "json" directive in Blade! pic.twitter.com/PbeAfZlzoF
— Taylor Otwell (@taylorotwell) September 18, 2017
Read more [twitter.com]
Nice hidden @laravelphp Eloquent feature: you can specify the columns to eager load directly in the 'with' call! pic.twitter.com/vQT8CaRqGC
— Stidges (@stidges) September 13, 2017
Read more [twitter.com]
This works in Laravel 5.5 because $request->validate() only returns the validated data. Beautiful.
Yeah. I had originally sent that PR. I love it. Makes for these lovely controller methods. Just look at this❗ pic.twitter.com/FlxIlJVQXN
— Joseph Silber (@joseph_silber) September 14, 2017
Read more [twitter.com]
Colin DeCarlo, a developer at Vehikl, wrote some thoughts on why PHP has a bad reputation in some circles.
People shitting on PHP isn’t going to go away, it’s a symptom of a few things. PHP has a ridiculously flat learning curve so just about anyone can write code using it, this means a lot of amateurs and ‘get it done’ developers will choose php but won’t really ever level up their skills when it comes to software development.
https://medium.com/@colindecarlo/who-uses-php-anyway-672115ab81de
I agree with Colin on everything he writes in his post. I'm also thinking that the some of the reasons on why people don't like PHP apply to Laravel as well. In my mind Laravel is to PHP frameworks what PHP is to other programming languages. Both Laravel and PHP might not do everything by the "real programming rules", but it sure is easy to use. And when handled properly powerful and maintainable stuff can be built with it.
Because Laravel is an easy framework to get started with, it's a popular choice for newcomers. Even with almost no experience you can build an app. Some of those projects will go to production. If an experienced developer that uses another framework comes by and sees that Laravel app, it might be easy to conclude that the problem lies with Laravel, and not with the inexperience of the junior programmer who just begon his/her journey in coding.