100 result(s) for βclassβ
Recently I discovered that this code passed our PHPStan level 10 checks: use http\Exception\InvalidArgumentException; // ... throw new InvalidArgumentException; I was surprised as http\Exception\InvalidArgumentException is not a class in our system. While cooling, I discovered t…
Today I wanted to have buttons for some Git features in my PHPStorm toolbar. Unfortunatley it doesn’t have icons for all the essential Git features, which results in empty buttons. Doesn’t look very nice. So I created some icons on my own. Use them if you like. Class…
I’m not an expert on probability theory, artificial intelligence, and machine learning. And even my Music 201 class from years ago has been long forgotten. But if you’ll indulge me for the next 10 minutes, I think you’ll find that even just a little knowledge can yield impressiv…
I was recently having a debate with a coworker over the utility of writing getter and setter methods for protected properties of classes. On the one hand, having getters and setters seems like additional boilerplate and programming overhead for very little gain. On the other han…
One of the cooler features of PHP 5.3 is the ability to package up a set of PHP class files and scripts into a single archive, known as a PHAR ("PHp ARchive"). PHAR files are pretty much equivalent to Java's JAR files: they allow you to distribute an entire library or applicatio…
If you're not using interfaces in PHP, you are missing out on a powerful object-oriented programming feature. An interface defines how to interact with a class. By defining an interface and then implementing it, you can guarantee a "contract" for consumers of a class. Interfaces…
Over on DZone, Giorgio Sironi demonstrates the "Open/Closed Principle on real world code". The pattern demonstrated is similar to the Command Pattern, and the post does a good job of introducing a class that is open for extension but closed for modification. Giorgio mentions tha…
In preparation for a presentation I’m giving at this month’s Syracuse PHP Users Group meeting, I found the need to read in Unicode characters in PHP one at a time. Unicode is still second-class in PHP; PHP6 failed and we have to fallback to extensions like the mbstring extension…
Laracon US 2026 is the flagship Laravel conference, returning to the East Coast on July 28-29, 2026 at the SoWa Power Station in Boston, Massachusetts. Join Laravel and PHP developers from around the world for two days of world-class talks, hands-on learning, and community conne…
Laravel 13.17.0 adds first-class route metadata support, Postgres transaction pooler integration, a dev:list command, and a Should Not Retry exception handler for queue jobs. The post Route Metadata Support in Laravel 13.17 appeared first on Laravel News. Join the Laravel Newsle…
Signal is a PHP library that reads attributes on your classes and methods and turns them into Markdown and JSON documentation through a single command. The post Turn PHP Attributes Into Docs With Signal appeared first on Laravel News. Join the Laravel Newsletter to get all the l…
I have a things-as-code project that outputs mostly text-based formats, but a lot of them. To keep an eye on consistency, I rebuild all the outputs and dump them into a local git repository so I can very easily diff to spot any changes – which was fine until we added a bui…
I consider myself pretty git-confident, I’ve worked with it a lot, taught it, been a git consultant, run engineering and various things-as-code teams. This week I had a spectactular git problem where merging one branch into another produced changes that didn’t exist …
I use a lot of asciidoc these days for work documentation (and I love it) and I’ve been so happy that GitHub renders it when you view a repository in the web browser, just like it does for Markdown and ReStructuredText. BUT what GitHub does not do is render the image types…
OpenAPI tags have always been annoying: user-supplied arbitrary data for endpoints should be a fabulous feature – but the documentation tools seem to think that tags are only for them so it becomes more difficult to use tags for other purposes. In fact it is very useful to…
OpenAPI has always had support for simple tags, but the OpenAPI 3.2 release brought in some serious tag upgrades including a summary field, a “kind” field with registry, – and the ability to nest tags which is the focus of today’s post. If one level of or…
Like many of you, my days are dominated by notifications. Emails from project management systems, source control systems, calendar invitations, ticket updates, and message about messages on other platforms. I’ve noticed that some people use notifications as a power tool, w…
Today I’m sharing a quick-and-dirty script to take an OpenAPI description, spin up a docs server locally, and copy the URL into your clipboard. I also use a bit of glob expansion in my script to find the right folder, because I have a lot of APIs with long and formulaic di…
The more I work on API standards, the more I realise how few teams understand that they can adopt the standards and, without breaking any contract, adapt them to make a strong interface for their own application. One of my favourite examples is to add enums where a standard inte…
PHP Internals News: Episode 100: Sealed Classes Thursday, March 24th 2022, 09:04 GMT London, UK In this episode of "PHP Internals News" I talk with Saif Eddin Gmati (Website, Twitter, GitHub) about the "Sealed Classes" RFC that he has proposed. The RSS feed for this podcast is h…
PHP Internals News: Episode 94: Unwrap Reference After Foreach Thursday, August 26th 2021, 09:22 BST London, UK In this episode of "PHP Internals News" I chat with Nikita Popov (Twitter, GitHub, Website) about the "First Class Callable Syntax" RFC. The RSS feed for this podcast …
PHP Internals News: Episode 92: First Class Callable Syntax Thursday, July 22nd 2021, 09:20 BST London, UK In this episode of "PHP Internals News" I chat with Nikita Popov (Twitter, GitHub, Website) about the "First Class Callable Syntax" RFC. The RSS feed for this podcast is ht…
What if every email you write could carry the rhetorical weight of Homer? Not as a gimmick, as a real tool that understands the tone, intent, and emotion of your message and finds the classical passage that fits. That’s the idea behind this PoC: a system that takes a short text …
TL;DR: Make your classes always final, if they implement an interface, and no other public methods are defined In the last month, I had a few discussions about the usage of the final marker on PHP classes. The pattern is recurrent: I ask for a newly introduced class to be declar…
Today I finally released version 1.0.0 of the ProxyManager Noticeable improvements since 0.5.2: Windows path length limitations are now mitigated Proxy classes are now re-generated when the library version changes Documentation has been moved to github pages (Markdown documentat…
by Yitzchak Schaffer (@yitznewton) As one of the first steps in a major new feature we are working on for EasyBib, we needed to introduce some polymorphism into the application. The polymorphic class was already implemented in another product; all that we needed to do was refact…
I am a visual learner. A picture is worth a thousand words. When I started learning Ruby, I could not find a decent diagram that would just sum up the Ruby classes, modules, and their hierarchy. So I made mine. By hand. On an A4 sheet. Here is the result (click for a full size v…
Python-oracledb rowfactories are a powerful way for Oracle Database queries to alter the representation of fetched rows, reducing the amount of application boilerplate code and data copying. This blog shows how easy it is to use a Python Data Class with a rowfactory to transform…
Privacy controls — systems that enforce retention, access, allowed-purpose, downstream-sharing, or anonymization policies — require a reliable understanding of data to function. Before such a control can operate effectively, it must know exactly what it is looking at. This can …
New Laravel 13 went all-in on PHP attributes. Properties like `$fillable`, `$guarded`, and `$hidden` that you've been defining on models for years can now be declared as class-level attributes: `#[Fillable]`, `#[Guarded]`, and `#[Hidden]`. The same applies to job configuration, …
I’d like to present my concept of inner classes for PHP based on other languages and PHP limitations. What are those inner classes? Nested Inner Class UML In object-oriented programming (OOP), an inner class or nested class is a class declared entirely within the body of a…
Recently I migrated this blog away from Tailwind to [Bulma](https://bulma.io) CSS framework, which uses a more semantical approach to CSS classes. Since this blog is a modern Symfony project, it uses Symfony Encore for providing frontend resources, and Symfony UX with the Hotwir…
For a long time I was extremely unhappy with the unresponsiveness of the features list in Tideways. The landingpage is using Bootstrap 3 since the beginning and its table-responsive class is supposed to help here, but requires visitors to scroll and loose context. See a screensh…
Last week the idea of changing PHP to include two languages "PHP" (Classic) and "P++" was proposed on the internals mailing list by Zeev and in more detail by a FAQ answering questions. For context, Zeev is one of the original authors of the Zend Engine in PH…
API Platform 3.3 is out and adds nice improvements once again! Many new options added to the Metadata classes, an increased focus on RDF at the heart of API design and a target to make API Platform more Laravel friendly. Many thanks to every contributor that made API Platform mo…
People don’t make purely rational decisions based on careful analysis of cost and expected utility, despite what classical economics taught us. Research findings confirm that our decisions are driven more by our emotions than logical and conscious thinking. However, our ir…
Final classes bring much more value than `extends` it lacks. It teaches composition over inheritance, makes upgrades easier, and [even mocking](/blog/2019/03/28/how-to-mock-final-classes-in-phpunit) is fine. If you're lazy like me, you can [automate the `final` keyword addition]…
In PHP, we have classes with methods inside them. Would making all your methods `public` be a good idea? No, because some of them should be used only by the class they're in and not anywhere else. What about class constants?
Final classes have [many](https://ocramius.github.io/blog/when-to-declare-classes-final/) [great](https://tomasvotruba.com/blog/2019/01/24/how-to-kill-parents) [benefits](https://matthiasnoback.nl/2018/09/final-classes-by-default-why/) for future human readers of your code. They…
When writing CSS for markup with weird class or id attribute values, you need to consider some rules. For example, you can’t just use ## { color: #f00; } to target the element with id="#". Instead, you’ll have to escape the weird characters (in this case, the second #). Doing so…
A sneak peak at some SPL goodies introduced in PHP 5.3: The GlobIterator and SplFileObject classes.
Context Around four years ago, I started to use Next.js in some projects, including this blog. These projects were not applications, but simple landing pages and documentation sites, where content written in markdown was a first class citizen. I remember that I was looking for a…
I was digging into Zend Expressive and how to use controllers that allow me to share dependencies between different routes, instead of having to use different middlewares every time. Abdul wrote a great article on this subject that you can find here, which also became part of Ex…
TLDR; Want StackPHP middleware in Laravel 5.0? Try barryvdh/laravel-stack-middleware Middleware and Laravel 4 In version 4.1, Laravel introduced compatibility with StackPHP middleware. As Laravel uses the Symfony HttpFoundation and the Application class implements the HttpKernel…
Consider the following code: class Animal { protected $what = "nothing"; function sound() { echo get_class($this)." says {$this->what}"; } } class Cow extends Animal { protected $what = "moo"; protected $owner; public function __construct($owner)…
This is the fourth post from a series of posts that will describe strategies to build modular and extensible applications. In this post we will start looking how to use "inheritance" to create a plugin based application. Inheritance is a characteristic offered by many class/obje…
I've been thinking about the affordances of programming languages. A Little Background In my previous post, Breaking Up the Behemoth, I posited an explanation for why OO apps so often evolve a few, disproportionally large, unmaintainable, condition-filled classes. Unfortunately,…
I've been teaching a fair amount, which means I've been revisiting my 'class problems' regularly. When I chose the problems, I thought that I understood them completely (hubris, I know) but now that I've worked them repeatedly I'm seeing new and surprising things. The…
You’re an object – Stand up straight and act like one! Imagine you have this code: Code 1: class MyView attr_reader :target def initialize(target) @target = target end def double case target when Numeric then target * 2 when String then target.next # lazy example fail when Array…
Yii2 DB Extension Installation Components A package of helper classes for working with databases in Yii2. Installation ¶Run php composer.phar require mspirkov/yii2-db or add "mspirkov/yii2-db": "^0.3" to the require section of your composer.json file. Components ¶ AbstractReposi…
Don't forget to like and subscribe :-) Intro ¶ Git Docker PSR Standards by Framework Interoperability Group Dependency injection + container 135 packages by Yii invoke() Theory around __invoke(): Hash annotations for class attributes Running the demo application Disclaimer Addin…
Haven’t found a better solution class Something < ActiveRecord::Base class JsonSymbolized def self.load(string) JSON.parse(string, symbolize_names: true) end def self.dump(object) object.to_json end end serialize :field, JsonSymbolized end
Released a generic Redis-based crawler for Ruby today. Very alpha. Use at your own risk. Has throttling, concurrency and some limits, but that’s about it. An example to parse a lot of Italian websites: require 'grucrawler' require 'colorize' class ItalianCrawler def option…
Wondering what `bg-current` does? Read this quick tip and wonder no longer!
Want to use the more classic look of links when using the Tailwind typography prose plugin? Here's how.
Here is how to add the Tailwind Typography plugin to Laravel Breeze to get the prose classes
Hello everyone! We’d like to announce the immediate availability of Codeception 2.4.0. This follows up the PHPUnit release and mostly contains compatibility fixes for PHPUnit 7. Internal usage of PHPUnit in Codeception was switched to new namespaced class names. This doesn’t bre…
Today the Codeception 2.3 sees the world. This is a stable release with almost no breaking changes but with new features you will probably like. At first, we need to say “thank you” to Luis Montealegre for bringing PHPUnit 6.0 support to Codeception. This is done by using class …
In this post we will explore some basics of user acceptance testing with Selenium. We will do this with classical unit testing framework PHPUnit, web browser Firefox, and with new php-webdriver library recently developed by Facebook. Selenium allows us to record user actions tha…
Documenting the system under test in PHPUnit You are working in a code base you inherited from someone else or have not touched in years. Customers have repeatedly asked for a feature or demanded that you fix a bug. You already know which class or classes you need to change, but…
Extending PHPUnit with its new event system You can extend phpunit/phpunit by creating and using abstract test classes and traits - or by using the event system of phpunit/phpunit. As one of the contributors to the new event system of phpunit/phpunit, I will give you an overview…
Avoiding imports and aliases in PHP PHP 5.3, released on June 30, 2009, introduced namespaces as well as imports and aliases. Developers quickly adopted these features. Where previously a class was named Foo_Bar_Baz_Qux, namespaces allow calling it Foo\Bar\Baz\Qux. Imports With …
Once you become familiar with Laravel, certain patterns start to stand out. Classes get resolved out of the container through facades, you can swap out instances inside of tests, entry points are predictable, configuration lives in familiar places. Laravel does this on purpose, …
I recently ran into a scenario where I wanted to register a couple of global options inside of a Laravel Zero project. These options need to be available for all commands inside of my project, but I didn't want to extend a custom base Command class. I tried a couple of things an…
After absolutely zero demand, I've added dark mode to my website. The front end is all styled with Tailwind so it didn't take too long, thankfully. Add a couple of dark: classes in various Blade templates and it just works. The one issue I did have was with syntax highlighted co…
Tailwind's Intellisense plugin for Visual Studio Code is great, but as somebody who uses Laravel Blade I am slowed down massively when writing Blade components or dynamic CSS class lists with the @class directive. If you open up your settings.json file inside of Visual Studio Co…
Over the last few days I am working on a new PHPStan capability, which allows PHPStan to use type information from analyzing a class-constructor with the goal to improve results when later on analyzing instance methods or property hook bodies. This feature will be available star…
I came across a subtle Octane but last week. We needed to disable Inertia’s history encryption in some places in the app. By default, it’s enabled everywhere. So we added a route check to the middleware to turn it off. class HandleInertiaRequests { public function ha…
In this brave new world, your margin is AI’s opportunity. When software becomes 10x easier to build, the classic “build vs. buy” calculation shifts dramatically. SaaS (Software as a Service) margins won’t disappear overnight, but it’s just a matter …
Back in 2024, the 37signals folks released Writebook, another cool product under their ONCE line of products. Writebook ("the easiest way on earth to publish a book online") features one of my favorite patterns: Delegated Types, which is a way to represent class hierarchies in A…
Cazuela is a neutral colored theme. Ilisa is a clean and minimal theme that can be easily used as a personal portfolio or a business website. Partition has a light, lively, colorful, yet professional and classic appearance.
Classy day. So this bug I was about hunt down is around the last couple of days. Almost gave up many times, not because I wanted to, it's just the way project managers try to kill the last happy moment of your life. And then, out of a sudden there are accusations. All sorts of t…
New in Drupal 11.1 The first feature release of Drupal 11 improves the recipe system, introduces support for hooks written as classes, makes Workspaces more flexible and enhances performance. Recipe system improvements The Recipe system allows packages to be configured with depe…
Completed Drupal site or project URL: https://www.concept2.com/DIGITAL TRANSFORMATION IN ECOMMERCE Concept2 Rising above the competition — Pursuing superior digital commerce in the fitness industry. Digital Transformation for a World-Class Fitness Manufacturer This case stu…
Over the last couple years, I’ve started putting my Exception messages inside static methods on custom exception classes. This is hardly a new trick, Doctrine’s been doing it for the better part of a decade. Still, many folks are surprised by it, so this article explains the how…
I've been using **[Obsidian](https://obsidian.md/)** for a couple of years now, and it has become my go-to companion for notes, data tracking, and knowledge management. Before landing on Obsidian, I went through quite the journey of note-taking tools: **Evernote**, then **Notion…
I'm currently working on a fairly JS-heavy project called Livewire. I'm not sure I've ever written m...
The PHP team has released PHP 8.2.0 on 8 Dec 2022. This version contains many new features like readonly classes, Disjunctive Normal Form (DNF) types, new "Random" extension, constants in traits, etc. I was curios to benchmark the execution time of this release compared with the…
My Very First Hackathon Rob, a classmate and good friend of mine, invited me to work with him and a few coworkers on their StaticShowdown team. He sent me the link, and I almost immediately replied yes. I'd never done a hackathon before, and this one looked especially fun, takin…
In this series, I show you new features and improvements to the Laravel framework since the original release of version 8. Last week, I wrote about the Collection class. This week is about the Database and Eloquent features in Laravel 8. The team added so many great improvements…
As you might know, the Laravel framework comes with a handy tap method which allows you to call the given closure with the given value and then return the value. Sounds confusing? It probably is until you've seen it! Let's take a look at this example: Lately we've used a Tappabl…
Besides the famous Collection class that Laravel provides it also has a Str class that has lots of great functions to work with strings. Some of these functions are available through helper functions and others you have to find in the API documentation. Last week we were working…
One undocumented gem I found today in the Laravel Framework is the withValidator method on a FormRequest class. If this method exists on your request class, this method gets called with the Validator instance as first argument. It allows you to interact with the validator instan…
I was recently assigned to work on a node.js project — a first, for me. I discovered that it comes with a neat CLI debugger built in, which is very handy when diving into an unknown codebase. However, when inspecting a variable, it doesn’t show me its type; only its...
When I was pretty young, maybe 13, I was interested in The Cure because my brother was interested in them. I think he had a big poster from one of the 80s classics – maybe for Boys Don't Cry? 1080p fast encode made from 4k original Screenshots from HQ 4k Version. Dow…
Welcome to our series of articles on PHP Design Patterns Games! In this article, we’ll be exploring the Adapter Pattern. This structural pattern allows incompatible interfaces to work together by wrapping the interface of an existing class with a new interface. The Adapter…
Working is extremely nice once you have a grasp on the basic concepts. But, one of the coolest promises (some pun intended) is the ability to use the render view helper. At its core, the render object lets you render a template with a view class wrapping it. However, the real po…
What higher-order components are, how they worked in class-based React, and why hooks are a better solution for the same cross-cutting concern problems.
It may seem silly, but it's important to me that my Tailwind classes are orderedly consistently, and I don't want to have to manage that manually. Frustratingly, I've never found a solution that gives me exactly what I want—until now. Here's my must-have list: Works in CLI…
Laravel 5.4 introduced a new feature called “real-time facades”, which provide the convenience of facades, defined real-time instead of in classes. Taylor tweeted about it, but I wanted to explain what they are and how they work. A quick introduction to facades in Laravel Alread…
Learn how to use Eloquent Query Classes to organize important database logic in Laravel without adding a full repository layer. Read more
How we use class-based Laravel Pennant features, with a kill switch on every flag and a config-driven path to general availability. Read more
Your Agent::fake() tests prove your Laravel AI feature runs — not that its output is any good. This evals a real ticket classifier with the AI SDK: a golden dataset for the fields you can check, an LLM-as-judge for the free text you can't, and a regression gate that catches a ba…
I am bored of PHP. Let's have fun with ::class!
Interface HowTo A great intro to refresh the basics In short: an interface defines what functionality you need in a class you depend on (while not caring about the implementation). It helps in designing the code and allows deferring implementation details, so they don’t get in t…
Introduction The latest Java Developer Preview (dp4) is hot off the press, and therefore I thought it would be a good idea to show you how to use some of the brand-new features that are now available. This post will show you how to use the new ComplexKey class for view queries a…
Motivation With modern NoSQL datastores on the rise, classical relational databases with their rigid data model get challenged every day. Nonetheless, they still own the market and therefore every developer needs to have solid skills in working with them in a reliable and perfor…