1. Go to this page and download the library: Download chevere/action 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/ */
chevere / action example snippets
use Chevere\Action\Interfaces\ActionInterface;
use Chevere\Action\Traits\ActionTrait;
class MyAction implements ActionInterface
{
use ActionTrait;
// ...
}
use Chevere\Action\Action;
class MyAction extends Action
{
// ...
}
class MyAction
{
protected function main(
string $value
): int
{
return mb_strlen($value) * 5;
}
}
use Chevere\Action\Action;
use Chevere\Parameter\Attributes\IntAttr;
use Chevere\Parameter\Attributes\ReturnAttr;
use Chevere\Parameter\Attributes\StringAttr;
class MyAction extends Action
{
#[ReturnAttr(
new IntAttr(min: 0, max: 100)
)]
protected function main(
#[StringAttr('/^ok/')]
string $value
): int {
return mb_strlen($value) * 5;
}
}
$action = new MyAction();
$result = $action('ok muy bueno');
use Chevere\Action\Interfaces\ParameterInterface;
use function Chevere\Parameter\string;
public static function return(): ParameterInterface
{
return string();
}
use Chevere\Action\Attributes\CallableAttr;
use Chevere\Action\Attributes\ReturnAttr;
use function Chevere\Parameter\string;
function myCallable(): StringParameterInterface
{
return string();
}
#[ReturnAttr(
new CallableAttr('myCallable')
)]
protected function main(): string
{
return 'chevere';
}
public static function mainMethod(): string
{
return 'altMain';
}
use Chevere\Controller\Controller;
class SomeController extends Controller
{
// ...
}
public function main(
string $pepito,
string $paysTwice
): array
{
// ...
}
use Chevere\Attributes\StringAttr;
public function main(
#[StringAttr('/^[a-z]$/')]
string $pepito,
#[StringAttr('/^[a-zA-Z]+$/')]
string $paysTwice
): array
{
// ...
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.