PHP code example of softrules / laravel

1. Go to this page and download the library: Download softrules/laravel library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

softrules / laravel example snippets


 declare(strict_types=1);

return [
    'forms' => [
        [
            'product' => 'testpagina',
            'uri' => env('SOFTRULES_MYTP_TESTPAGINA_URI'),
            'username' => env('SOFTRULES_MYTP_TESTPAGINA_USERNAME'),
            'password' => env('SOFTRULES_MYTP_TESTPAGINA_PASSWORD'),
        ],
        [
            'product' => 'volmachtproducten',
            'uri' => env('SOFTRULES_VOLMACHTPRODUCTEN_URI'),
            'username' => env('SOFTRULES_VOLMACHTPRODUCTEN_USERNAME'),
            'password' => env('SOFTRULES_VOLMACHTPRODUCTEN_PASSWORD'),
        ],
    ],
];

use SoftRules\PHP\UI\Components\Button;
use SoftRules\PHP\UI\Style\ButtonComponentStyle;
use SoftRules\PHP\UI\Style\StyleData;

Button::setStyle(new ButtonComponentStyle(
    default: new StyleData(class: 'btn btn-default'),
    primary: new StyleData(class: 'btn btn-primary'),
    success: new StyleData(class: 'btn btn-success'),
    danger: new StyleData(class: 'btn btn-danger'),
));

 declare(strict_types=1);

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use SoftRules\PHP\UI\Components\Button;
use SoftRules\PHP\UI\Style\ButtonComponentStyle;
use SoftRules\PHP\UI\Style\StyleData;

final class AppServiceProvider extends ServiceProvider
{
    public function boot(): void
    {
        Button::setStyle(new ButtonComponentStyle(
            default: new StyleData(class: 'btn btn-default'),
            primary: new StyleData(class: 'btn btn-primary'),
            success: new StyleData(class: 'btn btn-success'),
            danger: new StyleData(class: 'btn btn-danger'),
        ));
    }
}

use SoftRules\PHP\UI\Components\Button;
use SoftRules\PHP\UI\Style\ButtonComponentStyle;
use SoftRules\PHP\UI\Style\StyleData;

Button::setStyle(new ButtonComponentStyle(
    default: new StyleData(inlineStyle: 'background-color: #f00; color: #fff;'),
    primary: new StyleData(inlineStyle: 'background-color: blue; color: #fff;'),
    success: new StyleData(inlineStyle: 'background-color: green; color: #fff;'),
    danger: new StyleData(inlineStyle: 'background-color: red; color: #fff;'),
));

use SoftRules\PHP\UI\Components\Button;
use SoftRules\PHP\UI\Style\ButtonComponentStyle;
use SoftRules\PHP\UI\Style\StyleData;

Button::setStyle(new ButtonComponentStyle(
    default: new StyleData(class: 'bg-gray-300 text-gray-800'),
    primary: new StyleData(class: 'bg-blue-500 text-white'),
    success: new StyleData(class: 'bg-green-500 text-white'),
    danger: new StyleData(class: 'bg-red-500 text-white'),
));
bash
php artisan vendor:publish --tag=softrules-assets

"@php artisan vendor:publish --force --tag=softrules-assets --ansi"

"scripts": {
    "post-install-cmd": [
        //... default scripts
        "@php artisan vendor:publish --force --tag=softrules-assets --ansi"
    ],
    "post-update-cmd": [
        //... default scripts
        "@php artisan vendor:publish --force --tag=softrules-assets --ansi"
    ]
},