blast-project / core-bundle
这是 Libre Informatique Symfony2 项目的核心
Requires
- php: >=7.1
- doctrine/doctrine-bundle: >=1.6
- sensio/generator-bundle: >=3.1
- sonata-project/doctrine-orm-admin-bundle: >=3.1
- stfalcon/tinymce-bundle: >=2.1
- symfony/symfony: >=3.2
- willdurand/js-translation-bundle: ^2.6
Requires (Dev)
- mikey179/vfsstream: >=1.6
- phpunit/phpunit: ^6.4
- symfony/phpunit-bridge: >=3.2
This package is not auto-updated.
Last update: 2024-09-15 00:51:10 UTC
README
本组件的目标是在不编写任何 PHP 代码的情况下,实现使用 SonataAdmin "视图模型" 的功能,同时保留 Sonata 的所有功能,并引入大量使用管理员(其直接继承树、其实体使用的特性、其实体的继承树等)特性的复合设置理念,使事物更加灵活、可扩展、可重用和维护。
这是在 SonataAdminBundle 之后的下一步。配置整个后端组件,只需填写 YAML 文件...试试吧!
它也是 Libre Informatique 的 Symfony 2/3 项目的核心。
示例
我想设计并创建一个组件,作为其他组件实体的工具箱。例如,它将为电子邮件地址和电话号码提供特性(例如,参见 BlastBaseEntitiesBundle)。
使用 BlastCoreBundle,您的“基础”组件将携带特性,同时也可以在 SonataAdmin(成为 CoreAdmin)CRUD 中显示特性提供的属性。然后,在实现 BlastCoreBundle 的其他组件的实体中使用您的“基础”组件的特性,将自然添加字段,对象列表中的列等...就像您在“基础”组件中为特性设置的那样,无需为此编写任何代码。
想象一下,这个特性适用于 50 个分布在 10 个组件中的实体,并在心中计算节省的行数,避免的潜在错误数量以及当您想要更改提供的电子邮件地址或电话号码使用的字段性质时进行维护的便利性。这就是 BlastCoreBundle 允许的。
安装
先决条件
- 拥有一个工作的 Symfony2 环境
- 创建了一个工作的 Symfony2 应用(包括您的数据库和数据库连接)
- 已安装 composer(在此为 /usr/local/bin/composer,/usr/local/bin 在路径中)
下载
$ composer require blast-project/core-bundle dev-master
这将下载并安装
- knplabs/knp-menu
- knplabs/knp-menu-bundle
- cocur/slugify
- sonata-project/core-bundle
- sonata-project/cache
- sonata-project/block-bundle
- sonata-project/exporter
- twig/extensions
- sonata-project/admin-bundle
- sonata-project/doctrine-orm-admin-bundle
- blast-project/core-bundle
- libre-informatique/base-entities-bundle
- twig/twig ^1.22.1
第三方组件,Sonata 组件
请参阅 Sonata 项目的说明,可在此找到: https://sonata-project.org/bundles/admin/3-x/doc/reference/installation.html https://sonata-project.org/bundles/user/3-x/doc/reference/installation.html
并遵循安装指南。
最后,您应该有一个类似下面的 app/AppKernel.php
<?php use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\Config\Loader\LoaderInterface; class AppKernel extends Kernel { public function registerBundles() { $bundles = [ //... // Add your dependencies new Sonata\CoreBundle\SonataCoreBundle(), new Sonata\BlockBundle\SonataBlockBundle(), new Knp\Bundle\MenuBundle\KnpMenuBundle(), //... // If you haven't already, add the storage bundle // This example uses SonataDoctrineORMAdmin but // it works the same with the alternatives new Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle(), // You have 2 options to initialize the SonataUserBundle in your AppKernel, // you can select which bundle SonataUserBundle extends // Most of the cases, you'll want to extend FOSUserBundle though ;) // extend the ``FOSUserBundle`` //new FOS\UserBundle\FOSUserBundle(), //new Sonata\UserBundle\SonataUserBundle('FOSUserBundle'), // OR // the bundle will NOT extend ``FOSUserBundle`` //new Sonata\UserBundle\SonataUserBundle(), // Then add SonataAdminBundle new Sonata\AdminBundle\SonataAdminBundle(), new Blast\CoreBundle\BlastCoreBundle(), //... ]; //... } //... }
以及 app/config/config.yml
文件末尾
# ... sonata_block: default_contexts: [cms] blocks: # Enable the SonataAdminBundle block sonata.admin.block.admin_list: contexts: [admin] # Your other blocks
PostgreSQL
创建所需的数据库
如果您使用 PostgreSQL 作为主数据库,则需要安装 postgresql-contrib 并加载 "uuid-ossp" 扩展
$ sudo apt-get install postgresql-contrib
$ echo 'CREATE EXTENSION "uuid-ossp";' | psql [DB]
"libre-informatique" 组件
编辑您的应用/AppKernel.php文件,添加您的"libre-informatique"包,例如"libre-informatique/core-bundle"
// app/AppKernel.php // ... public function registerBundles() { $bundles = array( // ... // The libre-informatique bundles new Blast\CoreBundle\BlastCoreBundle(), // your personal bundles ); }
用法
使用YAML属性配置您的SonataAdminBundle接口
进一步...
了解更多关于CoreBundle以及如何改进SonataAdminBundle
配置独立包
使用CoreAdmin进一步...
除了Blast\CoreBundle\Admin\Traits\Base
特性外,您可能还感兴趣
Blast\CoreBundle\Admin\Traits\Embedded
:如果当前的CoreAdmin
旨在嵌入Blast\CoreBundle\Admin\Traits\Embedding
:如果当前的CoreAdmin
旨在嵌入其他表单,并且希望其嵌入字段自动处理
使用Sonata Project扩展
如果需要,您可以轻松地将BlastCoreBundle与其他Sonata Project的包结合使用,例如
- sonata-project/intl-bundle
- sonata-project/notification-bundle
- sonata-project/user-bundle
- sonata-project/formatter-bundle
请参阅Sonata Project的正确文档...