PHP
PHP Short Functions and Scope
Ross Wintle dissected the recent RFC for auto-capturing multi-statement closures in PHP. Read More
Ross Wintle dissected the recent RFC for auto-capturing multi-statement closures in PHP. Read More
Laravel recently added parallel testing to the framework using the Paratest package which runs PHPUnit in separate parallel processes. Adding support for this in your own package tests is pretty straightforward using orchestral/testbench. Read More
[AdSense-A]
Most developers have probably seen some complex conditionals in legacy code. In this video I show you how to refactor those.
(more…)Sidecar packages, creates, deploys, and executes Lambda functions from your Laravel application. Read More
An excellent post on the subject by Sarah Dayan. Read More
Tighten employees share encouragement for anyone struggling through the pandemic. Read More
[AdSense-A]
Sometimes it is not clear what the responsibility of a certain class is. This can be solved by adding a suffix to the class name.
(more…)Thanks to Doeke Norg personal access tokens became more flexible in Sanctum. In this blog post, he explains how you might use the new functionality Read More
[AdSense-A]
Our team has released a new package called file-system-watcher. As the name implies, this package can watch changes in the file system and let you act on those changes.
Here's a simple example that allows you to run some code when a new file gets added.
use SpatieWatcherWatch;
Watch::path($directory)
->onFileCreated(function (string $newFilePath) {
// do something...
})
->start();
After calling start
, the watcher will start a never-ending loop. When a file is created in the given $directory
, the closure passed in onFileCreated
will be executed.
There are methods for each kind of file change onFileCreated()
, onFileUpdated()
, onFileDeleted()
, onDirectoryCreated()
, onDirectoryDeleted()
.
Pretty simple, right?
Under the hood, this package leverages (https://github.com/paulmillr/chokidar), a popular JS library that can efficiently handle file system changes without requiring much memory or CPU.
To see a demo of the package and learn how we integrated our PHP code with a JS package, watch this fragment of a stream in which I introduced our file-system-watcher.
There are a few more options available in file-system-watcher. Head over to the readme on GitHub to learn more.
Be sure also to check out the packages our team has created previously. I'm sure there is something that you could use in your next project.
(more…)