1. Go to this page and download the library: Download palacios/framework 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/ */
final readonly class UsersController
{
public function __construct(
private IUserRepository $users,
) {}
}
#[HttpGet('/{id:int}')]
public function show(int $id): IActionResult
{
return Results::json(['id' => $id]);
}
use Palacios\Framework\Validation\Attributes\EmailAddress;
use Palacios\Framework\Validation\Attributes\Required;
use Palacios\Framework\Validation\Attributes\StringLength;
final class CreateUserInput
{
public function __construct(
#[Required]
#[StringLength(maximumLength: 120, minimumLength: 2)]
public string $name,
#[Required]
#[EmailAddress]
public string $email,
) {}
}
use Palacios\Framework\Database\Migration;
return new class implements Migration {
public function up(PDO $connection): void
{
$connection->exec(
'CREATE TABLE users (id INTEGER PRIMARY KEY, name VARCHAR(120) NOT NULL)',
);
}
public function down(PDO $connection): void
{
$connection->exec('DROP TABLE users');
}
};