I talk about code and stuff
“Run PHP” is a script to help run PHP scratch files when writing quick-and-dirty code. It has a couple of extra features over running a plain PHP file that can save a little bit of time.
You can install the package via Composer:
composer global require futureplc/run-php
To use, just call the command and pass through a file path as a single argument:
run-php /path/to/file/to/run.php
With this, we can run a file, reference classes and functions in our app without needing to import the autoloader, and not thinking about namespaces most of the time because they’ll be aliased for us.
<?php
$user = new User();
$user->name = 'Liam';
dd($user->getAttributes());
// Aliasing 'User' to 'App\Models\User'
//
// array:1 [
// "name" => "Liam"
// ]
Check it out here: