eduandebruijne / admin-bundle
A simple to use Symfony based CMS
Installs: 606
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 1
Type:symfony-bundle
Requires
- php: ^8.2
- doctrine/dbal: ^4.0
- doctrine/doctrine-bundle: ^2.12
- doctrine/orm: ^3.0
- league/glide: ^2.3
- oneup/flysystem-bundle: ^4.12
- symfony/asset: ^6.0 | ^7.0
- symfony/form: ^6.0 | ^7.0
- symfony/framework-bundle: ^6.0 | ^7.0
- symfony/http-client: ^6.0 | ^7.0
- symfony/security-bundle: ^6.0 | ^7.0
- symfony/translation: ^6.0 | ^7.0
- symfony/twig-bundle: ^6.0 | ^7.0
- symfony/validator: ^6.0 | ^7.0
- twig/twig: ^3.9
- dev-main
- 12.0.0
- 11.4.1
- 11.4.0
- 11.3.1
- 11.3.0
- 11.2.2
- 11.2.1
- 11.2.0
- 11.1.3
- 11.1.2
- 11.1.1
- 11.1.0
- 11.0.0
- 10.5.0
- 10.4.3
- 10.4.2
- 10.4.1
- 10.4.0
- 10.3.1
- 10.3.0
- 10.2.1
- 10.2.0
- 10.1.10
- 10.1.9
- 10.1.8
- 10.1.7
- 10.1.6
- 10.1.5
- 10.1.4
- 10.1.3
- 10.1.2
- 10.1.1
- 10.1.0
- 10.0.1
- 10.0.0
- 9.1.1
- 9.1.0
- 9.0.0
- dev-feature/forgot-password-flow
This package is auto-updated.
Last update: 2024-11-04 21:41:01 UTC
README
A simple to use Symfony based CMS
Installation Instructions
Install using Composer
composer require eduandebruijne/admin-bundle
Create User Entity
<?php declare(strict_types=1); namespace App\Entity; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\HasLifecycleCallbacks; use EDB\AdminBundle\Entity\AbstractUser; #[Entity] #[HasLifecycleCallbacks] class User extends AbstractUser { }
Create Media Entity
<?php declare(strict_types=1); namespace App\Entity; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\HasLifecycleCallbacks; use EDB\AdminBundle\Entity\AbstractMedia; #[Entity] #[HasLifecycleCallbacks] class Media extends AbstractMedia { }
Update config in config/packages/security.yaml
role_hierarchy: ROLE_ADMIN: ~ providers: user: entity: class: App\Entity\User property: username firewalls: main: custom_authenticators: - EDB\AdminBundle\Security\GoogleAuthenticator form_login: provider: user login_path: login check_path: check_form_login default_target_path: dashboard entry_point: form_login logout: path: logout access_control: - { path: ^/%env(EDB_ADMIN_PATH)%/login, roles: PUBLIC_ACCESS } - { path: ^/%env(EDB_ADMIN_PATH)%, roles: ROLE_ADMIN }
Use entities in config/packages/edb_admin.yaml
edb_admin: media_class: App\Entity\Media user_class: App\Entity\User
Get ready
- Make sure the
DATABASE_URL
in your.env
file is correct - Create and update the database schema
- Create your first admin user
bin/console doctrine:database:create --if-not-exists bin/console doctrine:schema:update --complete --force bin/console admin:create-user ROLE_ADMIN <required:username/email> <optional:password>
Optionally: Create User Admin
<?php declare(strict_types=1); namespace App\Admin; use App\Entity\User; use EDB\AdminBundle\Admin\AbstractUserAdmin; class UserAdmin extends AbstractUserAdmin { public function getEntityClass(): string { return User::class; } }
Optionally: Create Media Admin
<?php declare(strict_types=1); namespace App\Admin; use App\Entity\Media; use EDB\AdminBundle\Admin\AbstractMediaAdmin; class MediaAdmin extends AbstractMediaAdmin { public function getEntityClass(): string { return Media::class; } }
Other examples
Example Page Entity
<?php declare(strict_types=1); namespace App\Entity; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\HasLifecycleCallbacks; use EDB\AdminBundle\Entity\BaseEntity; use Doctrine\ORM\Mapping\Entity; #[Entity] #[HasLifecycleCallbacks] class Page extends BaseEntity { #[Column(type: 'string')] private ?string $title; public function __toString(): ?string { return $this->title; } public function getTitle(): ?string { return $this->title; } public function setTitle(?string $title): void { $this->title = $title; } }
Example Page Admin
<?php declare(strict_types=1); namespace App\Admin; use App\Entity\Page; use EDB\AdminBundle\Admin\AbstractAdmin; use EDB\AdminBundle\Admin\AdminInterface; use EDB\AdminBundle\FormBuilder\FormCollection; use EDB\AdminBundle\ListBuilder\ListCollection; use Symfony\Component\Form\Extension\Core\Type\TextType; class PageAdmin extends AbstractAdmin implements AdminInterface { public function buildForm(FormCollection $collection): void { $collection->add('title', TextType::class); } public function buildList(ListCollection $collection): void { $collection->add('title'); } public static function getAdminMenuTitle(): string { return 'Pages'; } public static function getEntityClass(): string { return Page::class; } }