1. Go to this page and download the library: Download codemonster-ru/annabel 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/ */
codemonster-ru / annabel example snippets
// public/index.php
R__ . '/../bootstrap/app.php';
$app->run();
// bootstrap/app.php
use Codemonster\Annabel\Application;
$baseDir = __DIR__ . '/..';
$app = new Application($baseDir);
class PackageServiceProvider extends ServiceProvider
{
public function register(): void
{
$this->commands([
SyncPackageCommand::class,
]);
}
}
use Codemonster\Annabel\Application;
use Codemonster\Annabel\Testing\InteractsWithApplication;
use PHPUnit\Framework\TestCase;
class FeatureTest extends TestCase
{
use InteractsWithApplication;
protected function createApplication(): Application
{
return
use Codemonster\ApiResource\JsonResource;
final class UserResource extends JsonResource
{
public function toArray(): array
{
return [
'id' => $this->resource->getKey(),
'name' => $this->resource->name,
];
}
}
return UserResource::paginated(
User::query()->simplePaginate(20, $page),
'/api/users',
)->response();
use Codemonster\Mail\Message;
mailer('log')->send(
Message::make()
->from('[email protected]', 'Annabel')
->to('[email protected]')
->subject('Welcome')
->text('Welcome to Annabel.'),
);
use Codemonster\Queue\Contracts\JobInterface;
class SendWelcomeEmailJob implements JobInterface
{
public function handle(): void
{
//
}
}
dispatch(new SendWelcomeEmailJob());
use Codemonster\Annabel\Http\ValidatesRequests;
use Codemonster\Http\Request;
class RegisterController
{
use ValidatesRequests;
public function store(Request $request): mixed
{
$data = $this->validate($request, [
'email' => '
$user = app(User::class, ['name' => 'Annabel']);
app()->bind(User::class, fn($container, array $params) => new User($params['name']));
$user = app(User::class, ['name' => 'Annabel']);
// Same for Application::make()
$user = $app->make(User::class, ['name' => 'Annabel']);