Some handy Carbon constants
?♂️⏲️ Just found all these handy class constants in Carbon - woohoo! ? pic.twitter.com/pL0HeKGVx4
— Caleb Porzio (@calebporzio) 29 juni 2018
Read more [twitter.com]
Posts tagged with php
?♂️⏲️ Just found all these handy class constants in Carbon - woohoo! ? pic.twitter.com/pL0HeKGVx4
— Caleb Porzio (@calebporzio) 29 juni 2018
Read more [twitter.com]
Joseph Silber, a very active Laravel contributor, has written a new blogpost on morph maps, a feature to decouple your database from your model class names.
Polymorphic relations let you set up a relationship between many different model types, without the need for extra tables. This works by storing the "morphable type" (explained below) in the database, in addition to the morphable type's ID. By default, the morphable type stored in the database is the model's full class name. While this works, it tightly couples your database to your PHP application. Let's look at how we can instruct Eloquent to use more generic values for these morphable types.
Read more [josephsilber.com]
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.
"Freek publishes a super resourceful and practical newsletter. A must for anyone in the Laravel space"
I often use Eloquent's `query` just to have the code better aligned#visualdebtisreal pic.twitter.com/0JWrzx6wEN
— Freek Van der Herten (@freekmurze) 2 juli 2018
Read more [twitter.com]
Mark Baker, serial conference speaker and creator of the PhpSpreadsheet package shares some thoughts on how to create private classes using anonymous classes.
I’ve written before about the benefits of using PHP’s Anonymous Classes for test doubles; but Anonymous Classes also have potential usecases within production code as well. In this article I’m going to describe one such usecase that can be particularly useful within libraries, and that is replicating the access of Package Private (in Java), or Protected Internal Classes (as per C#).
Read more [markbakeruk.net]
Just sent an email to internals@, detailing what I hope could be the beginning of a blueprint for PHP 8. It's a small step in what would hopefully be a long and fruitful journey.
— Zeev Suraski (@zeevs) June 25, 2018
Here's a sneak peak for the JIT part: pic.twitter.com/GMXXWvtRly
Read more [twitter.com]
? Customizing the error bag on a Laravel form request is as easy as setting a property. I find this comes in handy if a template might have multiple error checks. pic.twitter.com/b0lsP5oJ6G
— Paul Redmond ?? (@paulredmond) 26 juni 2018
Read more [twitter.com]
At Spatie We are currenlty building a new company website. One of the cool features is that it won't set a single cookie. In a new blogpost Dieter Stinglhamber explains how you can achieve this in Laravel.
Since May 25th you have been harassed by "We have updated our privacy policy" emails but also websites started to great you with "Please, let us and our 256 partners track you". In response to these abusive practices, some developers have decided to follow a better path, removing every cookie that is not needed.
Read more [dieterstinglhamber.me]
Sammy Kaye Powers, the host of the PHP Roundtable podcast, wrote a blogpost on how to compile PHP from source including unreleased RFC's. After following this tutorial you'll be able to play with the [typed properties] that are currently under discussion.
We'll be discovering and testing a completely unreleased feature of php-src from an RFC that's still under discussion. If you've ever wanted to be ahead of the curve of PHP features or you've just wanted to contribute back to PHP internals, testing an unreleased feature from an RFC is a fun and educational way to do so.
Read more [www.sammyk.me]
On the PHP internals mailing list Zeev Suraski, a long time core contributor of PHP, started a discussion on what PHP 8 could look like.
As I mentioned a few days ago I intended to send it slightly later - but as Nikita brought up the topic of PHP 8, this is probably as good a time as any to start the discussion. Please note: The goal of this email isn't to discuss in detail each and every topic that's mentioned, but rather to establish whether we want to move to focus on PHP 8 as we go beyond PHP 7.3, based on some of the research projects and PoCs we've been working on.
Read more [externals.io]
?? Use Eloquent's "->is()" method for more expressive and thorough assertions pic.twitter.com/8zx8AEm9Rw
— Caleb Porzio (@calebporzio) 22 juni 2018
Read more [twitter.com]
Recently I was working on a client project where a data import was performed via queues. Each record was imported in its own queued job using multiple queue workers. After the data import was done we had more rows than expected in the database. In this blogpost I'd like to explain why that happened.…
Mattias Noback shares how you can migrate a code base that fetches its dependencies using static method calls to code that uses dependency injection.
I've worked with several code bases that were littered with calls to
Zend_Registry::get(),sfContext::getInstance(), etc. to fetch a dependency when needed. I'm a little afraid to mention façades here, but they also belong in this list. The point of this article is not to bash a certain framework (they are all lovely), but to show how to get rid of these "centralized dependency managers" when you need to.
Read more [matthiasnoback.nl]
Joe Watkins, core PHP developer and author of (amongst many other things) ptrheads, is busy creating a PHP debugger written in PHP that you can just composer require.
This isn't just pipe dreams, the PHP code exists, it's alpha quality and largely untested ...There is much to do and you shouldn't design your workflow around this (or any alpha quality software) yet. What you should do is start reading code, testing, and opening pull requests...
You'll find the code of Joe's debugger in this repo on GitHub.
Read more [blog.krakjoe.ninja]
?♂️So you think that code always flows through either the if or else branch in a PHP script?
— Freek Van der Herten (@freekmurze) June 13, 2018
Hold my ?
----
<?php$pid = pcntl_fork();
if ($pid) {
echo 'in if';
}
else {
echo 'in else';
}
----
Try it out!#processcontrol #fun
Read more [twitter.com]
A GitHub repo containing easy to understand PHP snippets.
Read more [github.com]
? Super simple clean-up, but the cause of so much "dead code". When using `return` statements within a `switch` block the `break` is unnecessary and is always unnecessary for the `default` case. pic.twitter.com/QxjFmiGcYy
— Jason McCreary (@gonedark) June 11, 2018
Read more [twitter.com]
My buddy Frederick Vanbrabant, who is currently looking for a new opportunity, recorded a cool video course on how to build a PHP framework using some popular components. Here's the playlist that contains all the episodes.
Recently Taylor Otwell held a blogging competition. Entries could be submitted on a GitHub repo, the post with the highest amount of ? would win. My colleague Alex wrote a blogpost on how you could easily win the competition by hacking a bit. It's pretty awesome that Alex, without using any of the hacks described in the post, wound up winning the competition.
I feel like programmers are often as good at breaking things as they are at fixing things. Part of the thought process of programming anything new is figuring out its flaws, weaknesses and possible exploitations. As a web developer, I often find myself applying the same thought process to everything I see and read about online. Including Laravel's May Mayhem blog contest.
Read more [alexvanderbist.com]
A few weeks ago Matthieu Napoli released Bref, a tool to get any PHP project up and running in a serverless environment. Matthieu has managed to get working serverless too.
Serverless basically means “Running apps without worrying about servers”. The main difference with a traditional hosting is that you do not maintain the servers and reserve their capacity. They are scaled up or down automatically and you pay only for what you use. ... Today let’s try to deploy a Laravel application on AWS lambda using Bref.
Read more [mnapoli.fr]
#didyouknow that by type-hinting `offsetGet` and `current`, you can get autocompletion of custom Iterator and ArrayAccess classes in @phpstorm pic.twitter.com/Mr19b2gpye
— BrenDt (@brendt_gd) June 1, 2018
Read more [twitter.com]