PHP
Rationing Your Laravel Queue Workers Memory And CPU Consumption
If you’re running your queue workers on a server with limited resources, or a server that’s also used to serve HTTP requests and do other tasks, it’s important to ration the resource used by those Read more…
PHP
Validating Laravel Console Input
When distributing console commands in a package or within an application, making sure data is in the correct format can be important. Let’s build a make:user command that takes advantage of Laravel’s validation helpers. Read Read more…
PHP
Managing your DNS from GitHub with DNSControl
How you can leverage DNSControl and GitHub Actions to make DNS configuration a breeze. Read More
PHP
Styling Forms with Tailwind CSS
[AdSense-A]
Here's a very cool video by Simon Vrachliotis on how to style forms with the tailwindcss form plugin.
I could immediately use this knowledge to style some forms on this very blog.
(more…)PHP
★ Execute Artisan commands on remote servers
[AdSense-A]
Using the newly released spatie/laravel-remote package, you can quickly execute Artisan commands on a remote server.
Here's an example that will clear the cache on the remote server.
php artisan remote cache:clear
In this blog post, I'd like to tell you all about it!
Using laravel-remote #
You can install the package in any Laravel app using
composer require spatie/laravel-remote
No surprises there!
The package contains a remote
command that will connect to your remote server and execute a given artisan command there.
By setting these environment variables in your .env file, the package knows where to connect to. Here's an example for a site hosted on Forge.
#in your .env file
REMOTE_HOST=example.com
REMOTE_USER=forge
REMOTE_PATH=/home/forge/example.com
With this in place, you can clear the cache on your server with:
php artisan remote cache:lear
Of course, you can use an Artisan command you'd like.
If you want to execute a bash command, use the --raw
option.
Here we will get a list of files on the server.
php artisan remote ls --raw
You can define hosts in the config file. By default, the default
host is used. To execute a command on another host, use the --host
option.
php artisan remote cache:clear --host=my-other-host
Shorten the command using bash aliases #
For many years I have been aliasing "php artisan" to "a". This allows me to execute any artisan command very quickly.
a clear:cache
It's a small improvement, but I'm sure that the alias has saved me quite some time summed up over all the years.
I've now added another alias, "ar," which maps to "php artisan remote".
ar clear:cache
It's pretty cool with how little efforts this allows me to execute commands on a remote server.
How it works under the hood #
When executing remote
, the package will connect to your server via SSH, cd to your app's directory, and execute the command.
In this streaming session, you can see me build up the package from scratch.
In closing #
I think spatie/laravel-remote can save you a lot of time if you regularly want to execute commands on a remote server.
Be sure to take a look at this list of packages our team has created previously.
(more…)PHP
Building a Laravel package from scratch
In this streaming session, you can see me build up the package from scratch. You can find the code seen in the stream in the spatie/laravel-remote repo on GitHub. If you want to learn how Read more…
PHP
★ Introducing monthly playlists from team Spatie
[AdSense-A]
At Spatie, each one of our team members loves music. Scattered across our office are a couple of HomePods. Everyone in our team is free to stream his favourite music for others to hear (of course at an acceptable volume so everyone can still work).
This is a great way to discover music. In my mind, any automated algorithm that picks music for you is trumped what your friends and peers suggest to you.
Because of the pandemic, this way of sharing music with each other was lost. That's why our team will from now on create monthly playlists. The process is easy: every month we will choose a theme for the playlist and each team member picks two or three tracks.
The first theme is "Late Night Something" (it's not "late night coding" because not everyone on our team codes.
Here's our playlist on Apple Music. And here is the same playlist on Spotify.
Here's at the Spotify embed so you can listed from your browser too.
I hope you'll enjoy these tracks as much as we do! I'm already looking forward to next month's playlist.
(more…)PHP
★ A practical look at multi tenancy in Laravel
In this talk, given at Laracon Online 2020, I show a simple strategy to make any Laravel app tenant aware using our laravel-multitenancy package.
PHP
★ Debug apps running on remote servers using Ray
[AdSense-A]
Earlier this year, we released Ray, a desktop app that allows you to debug faster. Instead of dumping values to the browser or console, Ray allows you to display debugging information beautifully in a dedicated window.
Since launch, Ray helps you debug local projects. Today, we're adding the most requested feature to Ray: the ability to connect to remote servers. All output of the ray()
call, will be sent securely from your remote server to the local app via SSH.
Using this feature, you can quickly investigate problems on your production servers that you are unable to recreate locally.
In this short video you'll see a quick demo!
If you're not familiar with Ray yet, read this blogpost on why we created Ray and how you can use it. Do also check out the docs and promotional site.
Since launch, our team has added a lot of features. If you have any feature request or questions, let us now via the discussions tab on spatie/ray.
(more…)