fschirinzi/laramote

Laravel Remote

v2.1.0 2022-01-17 10:38 UTC

This package is auto-updated.

Last update: 2024-12-17 17:10:57 UTC


README

Test StyleCI Latest Version on Packagist Total Downloads

LaraMote allows you to run tasks in Laravel from remote. This package is helpful if you are testing your frontend (SPA) application with Cypress that uses a Laravel application as backend.

At the moment, these features are implemented:

✅ Artisan command
       ✅ Command with parameters
       ✅ Get Output
✅ Login User
       ✅ Custom key value
       ✅ Custom key/table column
       ✅ Custom model
       ✅ Remember
✅ Factory
       ✅ Make/Create
       ✅ Models
       ✅ Name
       ✅ States
       ✅ Amount
       ✅ Show hidden attributes
       ✅ Override attributes
✅ Model
       ✅ Search with custom key value
       ✅ Search with custom key/table column
       ✅ Search with custom model
       ✅ Get with limit
       ✅ Load relationships
       ✅ Show hidden attributes for model and relationships

TODO

  • Make Commands working
  • Make Tests
  • Add wiki page with all endpoints and their parameters
  • Support all class based factory features

Installation

You can install the package via composer:

composer require fschirinzi/laramote --dev

After installing LaraMote, you may publish its assets using the laramote:install Artisan command:

php artisan laramote:install

Usage

LaraMote exposes the endpoints at the /laramote URI. By default, you will only be able to access this dashboard in the local and testing environment. However, within your app/Providers/LaraMoteServiceProvider.php file, there is a gate method that controls access to the LaraMote endpoints in non-local environments. You are free to modify this gate as needed to restrict access to your LaraMote endpoints:

/**
 * Register the LaraMote gate.
 *
 * This gate determines who can access LaraMote in non-local environments.
 *
 * @return void
 */
protected function gate()
{
    Gate::define('useLaraMote', function ($user = null) {
        return in_array(optional($user)->email, [
            //
        ]);
    });
}

Examples

You can import Insomnia_example_requests.json into the Insomnia Rest-client to see some examples in action.

Upgrading

When upgrading to a new version of Laramote, you should re-publish LaraMote's assets:

php artisan laramote:publish

To keep the assets up-to-date and avoid issues in future updates, you may add the laramote:publish command to the post-update-cmd scripts in your application's composer.json file:

Customizing Middleware

If needed, you can customize the middleware stack used by LaraMote routes by updating your config/laramote.php file. If you have not published LaraMote's configuration file, you may do so using the vendor:publish Artisan command:

php artisan vendor:publish --tag=laramote-config

Once the configuration file has been published, you may edit LaraMote's middleware by tweaking the middleware configuration option within this file:

/*
|--------------------------------------------------------------------------
| LaraMote Route Middleware
|--------------------------------------------------------------------------
|
| These middleware will be assigned to every Vapor UI route - giving you
| the chance to add your own middleware to this list or change any of
| the existing middleware. Or, you can simply stick with this list.
|
*/

'middleware' => [
    'api',
    EnsureUserIsAuthorized::class,
],

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email fschirinzi25@gmail.com instead of using the issue tracker.

Credits

I used the Laravel/VaporUi package and their documentation as template to speed up the development of this package.

License

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

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.