PHP
Useful String Methods In JavaScript.
Strings are useful for holding data that can be represented in text form. Some of the most-used operations on strings are to check their length, to build and concatenate them using the + and += Read more…
Strings are useful for holding data that can be represented in text form. Some of the most-used operations on strings are to check their length, to build and concatenate them using the + and += Read more…
It looks like PHP will get fibers soon with PHP 8.1! Thatâs awesome! Or is it? Read More
As a predominantly Laravel developer that is accustomed to Laravel Mix, I wanted to see how to get Tailwind’s JIT compiler working with Laravel Mix, and was pleasantly surprised that it was quite simple and Read more…
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…
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…
How you can leverage DNSControl and GitHub Actions to make DNS configuration a breeze. Read More
[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…)[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!
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
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.
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.
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…)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…