gbuckingham89/valet-assistant

This package is abandoned and no longer maintained. No replacement package was suggested.

A Laravel package for using Laravel Valet within another Laravel application - e.g. getting a list of sites served by Valet.

0.2.0 2022-01-05 20:56 UTC

This package is auto-updated.

Last update: 2024-04-06 02:00:38 UTC


README

Latest Version on Packagist GitHub Tests Action Status Total Downloads

A Laravel package for using Laravel Valet within another Laravel application - e.g. getting a list of sites served by Valet.

This package will only be fully functional when used on a computer that has Laravel Valet installed.

Looking for a UI for Laravel Valet? Take a look at gbuckingham89/valet-launchpad.

Installation

You can install the package via composer:

composer require gbuckingham89/valet-assistant

You can publish the Laravel config file with:

php artisan vendor:publish --tag="valet-assistant-config"

Usage

Use the Laravel container to resolve a copy of Gbuckingham89\ValetAssistant\ValetAssistant however you feel is best - e.g. dependency injection or via app()->make().

There is also a Facade, Gbuckingham89\ValetAssistant\Facade\ValetAssistant, if that's your preference.

Once you have your instance, you can use the following methods:

Get a list of all the projects served by Laravel Valet:

$valetSites = $valetAssistant()->projects();

This returns a Collection of "Project" objects (representing a directory on your local machine). Each Project will have one or more "Site" objects (representing a URL that the project is served under). Take a look at the source code or use auto-completion in your IDE to learn more about the data structure.

Check is Valet is installed (and accessible):

$valetIsInstalled = $valetAssistant()->isInstalled();

This simply returns a boolean value indicating if Valet is installed, or not.

Troubleshooting

Valet not installed

If you see errors about Valet not being installed (but you're sure that it is, and you see output by running which valet from your local terminal) it's likely that the user running your PHP script doesn't know where the Valet binary is located, or doesn't have permission to run it.

There are two ways to resolve this;

  1. Find the value of the PATH environment variable for your shell by running echo $PATH from your local Terminal. Ensure you have published the config file (see above), then add an entry to your .env file with the key VALET_ASSISTANT_ENV_PATH and the value of your local PATH. This PATH value will then be used whenever this package executes a shell command. It is NOT used by code outside this package.
  2. Add /Users/[local-username]/.composer/vendor/bin to the PATH environment for the user running the PHP script (remember to insert the username that Valet is installed under)

Please do your own research and consider any security implications of giving PHP access to additional directories through the PATH environment.

Testing

You can run the test suite by calling ./vendor/bin/phpunit or composer test.

You may see the following error in your terminal output when running the test suite: ..sh: which: command not found. This is a known issue and a PR to resolve this would certainly be welcomed!

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.