klsoft / yii3-cms
A content management system based on the Yii3 framework that uses the Doctrine ORM. It can be customised using the Composer package manager.
Requires
- php: ^8.2
- ext-filter: *
- httpsoft/http-message: ^1.1.6
- klsoft/yii3-cms-admin-bootstrap5: ^1.0
- klsoft/yii3-cms-site-bootstrap5: ^1.0
- yiisoft/aliases: ^3.1.1
- yiisoft/assets: ^5.1.2
- yiisoft/config: ^1.6.2
- yiisoft/csrf: ^2.2.3
- yiisoft/di: ^1.5.0
- yiisoft/error-handler: ^4.3.3
- yiisoft/html: ^4.3
- yiisoft/http: ^1.4
- yiisoft/input-http: ^1.0.1
- yiisoft/log: ^2.2.1
- yiisoft/router: ^4.0.2
- yiisoft/router-fastroute: ^4.0.3
- yiisoft/session: ^3.0.3
- yiisoft/translator-message-php: ^1.1.3
- yiisoft/yii-console: ^2.4.2
- yiisoft/yii-runner-console: ^2.2.1
- yiisoft/yii-runner-http: ^3.2.1
- yiisoft/yii-view-renderer: ^7.4.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.95.32
- vimeo/psalm: ^7.24.1
- vlucas/phpdotenv: ^5.8.1
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
It is a content management system based on the Yii3 framework that uses the Doctrine ORM. It can be customised using the Composer package manager.
Features
- Create and manage pages, posts, and navigation.
- Design SEO-friendly URLs.
- Manage permissions.
Requirements
- PHP 8.2 or higher.
How to use
- Create a new project from a template using the Composer package manager:
composer create-project klsoft/yii3-cms my_site
cd my_site
- Configure the Doctrine connection in the
config/common/params.php. - Set the
encryptorKeyparameter in theconfig/web/params.php. - Create and initialise the database schema:
./yii init
- To run the application:
./yii serve
To run the application using the specified options:
./yii serve --address=127.0.0.1 --port=8080
Open your browser to the URL http://localhost:8080
If you would prefer to use a different web server, please refer to the Configuring web servers section. To achieve the best performance, use the Swoole HTTP server via the klsoft-web/yii3-swoole package.
How to use with Docker
- Clone the repository.
- Uncomment the line
'host' => 'mysql'in theconfig/common/params.php - Set the
encryptorKeyparameter in theconfig/web/params.php. - Start the application:
docker compose up -d
- Create and initialise the database schema:
docker compose exec app ./yii init
Open your browser to the URL http://localhost:8080
Yii3 CMS Structure
The Yii3 CMS has two default parts: public and administrative. The public part is provided by the klsoft-web/yii3-cms-site-bootstrap5 package. The administrative part is provided by the klsoft-web/yii3-cms-admin-bootstrap5 package.
You can replace either of these parts using the Composer package manager. First install the new part with the composer require new-part command, then remove the old part with the composer remove old-part command.
Developing a package for the Yii3 CMS
To adjust the number of parts in the Yii3 CMS, use the['config-plugin']['routes'] parameter in the config/configuration.php file. All parts except one must include a configuration parameter key and a route prefix.
When creating a package for the Yii3 CMS, you can use the provided parameters or develop your own.
The parameters for the public part:
//config/params.php return [ 'klsoft/yii3-cms' => [ 'routes' => [ Group::create() ->routes( // ... ), ], 'fallbackHandler' => Reference::to(NotFoundHandler::class), 'layout' => '@vendor/klsoft/yii3-cms-site-bootstrap5/src/Presentation/Shared/Layout/Main/layout.php', ], ];
You can override the ['klsoft/yii3-cms']['routes'] parameter in the config/common/yii3-cms-routes.php file, as well as the ['klsoft/yii3-cms']['fallbackHandler'] and ['klsoft/yii3-cms']['layout'] parameters in the config/web/di/application.php file.
The parameters for the administrative part:
//config/params.php return [ 'klsoft/yii3-cms' => [ 'admin' => [ 'routes' => [ Group::create(prefix: '/admin') ->routes( // ... ), ] ], ];
You can override the ['klsoft/yii3-cms']['admin']['routes'] parameter in the config/common/yii3-cms-admin-routes.php file.
To develop your own set of entities, create a package and add the following configuration to the config/di.php file:
//config/di.php use Doctrine\Persistence\Mapping\Driver\ClassLocator; use Doctrine\Persistence\Mapping\Driver\ClassNames; return [ ClassLocator::class => new ClassNames( [ MyEntity::class ] ), ];
Note that all parts of Yii3 CMS have to depend on the same package containing the set of entities. Use the klsoft/yii3-cms-entities package as a sample.