guardsmanpanda/larabear

Make Project Strong Like Bear.

v1.0.0 2024-03-13 21:29 UTC

This package is auto-updated.

Last update: 2024-05-18 18:03:08 UTC


README

Latest Version on Packagist Total Downloads

Larabear

Make Laravel strong like bear!

Installation

You can install the package via composer:

Step 1

composer require guardsmanpanda/larabear

Step 2

Add the Service provider to config/app.php:

    'providers' => [
        Illuminate\Auth\AuthServiceProvider::class,
        Illuminate\Broadcasting\BroadcastServiceProvider::class,
        ...
        \GuardsmanPanda\Larabear\Infrastructure\Laravel\Provider\BearServiceProvider::class,
    ],

Step 3

Publish the required config file:

php artisan vendor:publish --tag=bear

Step 4

To test and verify that the system is configured properly you can run

php artisan bear

Step 5

To enable the majority of the functionality make sure that the "BearInitiateMiddleware" is enabled on all routes

final class HttpKernel extends Kernel {
    // These middlewares are run during every request to your application.
    protected $middleware = [
        \GuardsmanPanda\Larabear\Infrastructure\Http\Middleware\BearInitiateMiddleware::class,
        OtherMiddleware::class,
    ];

Step 6

To filter console output from "php artisan" changed main artisan file to:

#!/usr/bin/env php
<?php declare(strict_types=1);

use GuardsmanPanda\Larabear\Infrastructure\Console\Service\ConsoleOutputFilter;

define('LARAVEL_START', microtime(true));

require __DIR__.'/vendor/autoload.php';
$app = require __DIR__.'/bootstrap/app.php';

$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
$status = $kernel->handle($input = new Symfony\Component\Console\Input\ArgvInput, new ConsoleOutputFilter);

$kernel->terminate($input, $status);
exit($status);

Usage

You can get proper type check data from the request by using the "Req" class:

final class MyController extends Controller {
    public function myMethod(): JsonResponse {
        $data = Req::getString('data');

Security

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

Credits

License

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