PHP code example of php-concept / core
1. Go to this page and download the library: Download php-concept/core 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/ */
php-concept / core example snippets
declare(strict_types=1);
use Concept\Core\App;
$rootPath = dirname(__DIR__);
$paths = otstrap/providers/app.php',
]);
return $app;
declare(strict_types=1);
$app =
declare(strict_types=1);
use Symfony\Component\Console\Application as ConsoleApplication;
$app = leApplication $console */
$console = $app->getContainer()->get(ConsoleApplication::class);
exit($console->run());
declare(strict_types=1);
namespace Concept\Components\AuthAdmin;
use Concept\Core\Services\Component\Contracts\ComponentInterface;
use Concept\Core\Services\Database\Contracts\SeederInterface;
use League\Container\ServiceProvider\ServiceProviderInterface;
use Symfony\Component\Console\Command\Command;
class AuthAdminComponent implements ComponentInterface
{
public function name(): string
{
return 'auth-admin';
}
public function version(): string
{
return '1.0.0';
}
public function description(): string
{
return 'Admin authentication module';
}
public function routes(): ?string
{
return __DIR__ . '/routes.php';
}
/** @return class-string<ServiceProviderInterface>[] */
public function providers(): array
{
return [];
}
/** @return class-string[] */
public function viewExtensions(): array
{
return [];
}
/** @return array<string, string> */
public function viewPaths(): array
{
return ['auth-admin' => 'src/Components/AuthAdmin/Views'];
}
/** @return array<string, string> */
public function viewContexts(): array
{
return ['/admin' => 'dashboard'];
}
/** @return class-string<Command>[] */
public function commands(): array
{
return [];
}
/** @return class-string<SeederInterface>[] */
public function seeders(): array
{
return [];
}
/** @return list<string> migration directory paths */
public function migrations(): array
{
return [__DIR__ . '/Database/Migrations'];
}
/** @return array<string, string> */
public function assets(): array
{
return [];
}
}
// config/components.php
return [
'components' => [
AuthAdminComponent::class,
],
];
$router->group('/admin/users', function (RouteGroup $route) {
$route->get('/', [UserController::class, 'index'])->setName('admin.users');
$route->post('/store', [UserController::class, 'store'])->setName('admin.user.store');
})->lazyMiddleware(AuthMiddleware::class);
$url = $urlGenerator->uri('admin.user.edit', ['id' => 5]);
return [
'routes' => [
'interceptors' => [
AclRouteAuthorization::class, // implement RouteInterceptorInterface
],
'list' => [__DIR__ . '/../routes/web.php'],
],
];
return $this->response->json(['users' => $users]);
return $this->response->jsonSuccess($data);
return $this->response->jsonError('Not found', 404);
return $this->response->redirectByName('admin.users');
return $this->viewResponse->create('@dashboard/index', ['title' => 'Home']);
/** @extends FormRequest<StoreUserDto> */
class StoreUserRequest extends FormRequest
{
protected ?string $dtoClass = StoreUserDto::class;
protected array $except = ['password_confirmation'];
public function rules(): array
{
return [
'name' => ['
public function store(StoreUserRequest $request): ResponseInterface
{
$dto = $request->toDto(); // Valinor-mapped immutable DTO
$data = $request->validated(); // plain array
// ...
}
// config/view.php (app-level)
return [
'view' => [
'paths' => [
'dashboard' => 'resources/views/dashboard',
],
'contexts' => [
'/admin' => 'dashboard', // auto-select layout namespace by URL prefix
],
'extensions' => [
UrlGeneratorTwigExtension::class, // your Twig extension
],
],
];
bash
php bin/console.php route:list
php bin/console.php route:list --full-middleware
bash
php bin/console.php db:migrate
php bin/console.php db:rollback
php bin/console.php migration:list
php bin/console.php db:seed
php bin/console.php db:seed -c "Concept\Components\AuthAdmin\Database\Seeders\UserSeeder"
php bin/console.php seeders:list
bash
php bin/console.php view:clear