PHP code example of shworx / beacon

1. Go to this page and download the library: Download shworx/beacon 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/ */

    

shworx / beacon example snippets


// routes/web.php
$router->get('/', [HomeController::class, 'index'], 'home');
$router->post('/', [MyController::class, 'submit'], 'home.submit');

// routes/web.php
$router->get('/my-route/{first}/{second}', [MyController::class, 'myMethod'], 'my-name');

// app/Controllers/MyController.php
public function myMethod($first, $second): Response {
    ...
}

$router->group(
    prefix: '',
    callback: function (Router $router) {
        $router->get('/dashboard', [DashboardController::class, 'index'], 'dashboard');
    },
    middleware: [AuthMiddleware::class]
);

// app/DTO/LoginDto.php
namespace App\DTO;

use Symfony\Component\Validator\Constraints as Assert;

final readonly class LoginDto
{
public function __construct(
#[Assert\NotBlank]
#[Assert\Email]
public string $email,

        #[Assert\NotBlank]
        public string $password,
    ) {}
}

// app/Controllers/LoginController.php

$dto = LoginDto::fromArray($request->all());
$validator->validate($dto);

$user = User::query()
    ->where('email', $email)
    ->first();

$prt = PasswordResetToken::with('user')
    ->where('token_hash', $tokenHash)
    ->first();

php console migrate
shell
php console migrate
shell
openssl dhparam -out ./docker/config/ssl/dhparam.pem 4096