panda-fire/core-bundle
Composer 安装命令:
composer require panda-fire/core-bundle
包简介
Let the bundle organize your tasks efficiently
README 文档
README
Introduction
Imagine a world in which you have numerous tasks to perform with their respective due dates. Imagine that those tasks, tell you the right order to get everything done. Imagine that those tasks could let you know that you are trying to do something impossible. This is how PandaFire was born and what it wants to accomplish for you.
All you need to know is your task due date and its length. Then click. PandaFire will immediately tell you its feasibility and when to do it to be the most efficient as possible.
Because you want to get things done.
Installation
Download the plugin via composer
$ composer require panda-fire/core-bundle
Enable plugin
In the app/AppKernel.php file, add the following lines
<?php use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\Config\Loader\LoaderInterface; class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // other bundles ... new PandaFire\CoreBundle\PandaFireCoreBundle(), return $bundles; }
Create user and task classes using XML
User
<!-- AppBundle/Resources/config/doctrine/User.orm.xml --> <?xml version="1.0" encoding="utf-8"?> <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> <entity name="AppBundle\Entity\User" table="user"> <id name="id" type="integer"> <generator strategy="AUTO" /> </id> <!-- PandaFire required properties --> <field name="startWorkingHour" type="integer" column="start_working_hour" /> <field name="endWorkingHour" type="integer" column="end_working_hour" /> <field name="startBreakHour" type="integer" column="start_break_hour" /> <field name="endBreakHour" type="integer" column="end_break_hour" /> <field name="daysOff" type="array" column="days_off" nullable="true" /> <one-to-many target-entity="AppBundle\Entity\Task" mapped-by="owner" field="timeSortableItems" /> <!-- End PandaFire required properties --> </entity> </doctrine-mapping>
<?php // src/AppBundle/Entity/User.php namespace AppBundle\Entity; use PandaFire\CoreBundle\Model\TaskOwner; class User extends TaskOwner { // your custom logic }
Task
<!-- AppBundle/Resources/config/doctrine/Task.orm.xml --> <?xml version="1.0" encoding="utf-8"?> <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> <entity name="AppBundle\Entity\Task" table="task" repository-class="PandaFire\CoreBundle\Repository\ORM\TimeSortableItemRepository"> <id name="id" type="integer"> <generator strategy="AUTO" /> </id> <many-to-one target-entity="User" field="owner" inversed-by="timeSortableItems"> <join-column on-delete="CASCADE" /> </many-to-one> </entity> </doctrine-mapping>
<?php // src/AppBundle/Entity/Task.php namespace AppBundle\Entity; use PandaFire\CoreBundle\Model\TimeSortable; class Task extends TimeSortable { /** * @var User */ protected $owner; }
Configuration
Configure the PandaFireCoreBundle :
panda_fire_core: db_driver: orm # Only driver supported at the moment task_class: AppBundle\Entity\Task # Your "task" object class
Run migrations
Update your schema using the following command
$ php app/console doctrine:schema:update --force
Go further
Integration with FOSUserBundle
- Install and configure FOSUserBundle
- Create entities
- Enable the bundle
- Update your database schema
Step 1 : FOSUserBundle installation & configuration
Install the FOSUserBundle as specified in the related documentation. Once everything is fine, proceed to the following steps.
Step 2 : Create entities
Add the required properties to your Resources/config/doctrine/User.orm.xml model configuration file as follow:
<?xml version="1.0" encoding="utf-8"?> <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> <entity name="AppBundle\Entity\User"> <id name="id" type="integer"> <generator strategy="AUTO" /> </id> <!-- PandaFire --> <field name="startWorkingHour" type="integer" column="start_working_hour" /> <field name="endWorkingHour" type="integer" column="end_working_hour" /> <field name="startBreakHour" type="integer" column="start_break_hour" /> <field name="endBreakHour" type="integer" column="end_break_hour" /> <field name="daysOff" type="array" column="days_off" nullable="true" /> <!-- End PandaFire --> <one-to-many target-entity="Task" mapped-by="owner" field="timeSortableItems" /> </entity> </doctrine-mapping>
To easily add the getters/setters of your class, just use the Trait provided :
<?php namespace AppBundle\Entity; use FOS\UserBundle\Model\User as FOSUser; use PandaFire\CoreBundle\Model\TaskOwnerTrait; class User extends FOSUser { use TaskOwnerTrait; }
Create a Task entity starting with the mapping file in AppBundle/Resources/config/doctrine/Task.orm.xml ...
<?xml version="1.0" encoding="utf-8"?> <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> <entity name="AppBundle\Entity\Task" repository-class="PandaFire\CoreBundle\Repository\ORM\TimeSortableItemRepository"> <id name="id" type="integer"> <generator strategy="AUTO" /> </id> <many-to-one target-entity="User" field="owner" inversed-by="timeSortableItems"> <join-column on-delete="CASCADE" /> </many-to-one> </entity> </doctrine-mapping>
And its entity file in AppBundle/Entity/Task.php :
<?php namespace AppBundle\Entity; use PandaFire\CoreBundle\Model\TimeSortable; class Task extends TimeSortable { /** * @var User */ protected $owner; }
Note that the property $owner don't have to be defined but makes type hinting more developer friendly ;-)
Step 3 : Enable the bundle
Enable the plugin in your app/AppKernel.php file :
<?php use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\Config\Loader\LoaderInterface; class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // other bundles ... new AppBundle\AppBundle(), new FOS\UserBundle\FOSUserBundle(), new PandaFire\CoreBundle\PandaFireCoreBundle(), return $bundles; }
Configure the bundle in your app/config/config.yml :
panda_fire_core: db_driver: orm # Only supported driver at the moment task_class: AppBundle\Entity\Task # You task entity class
Step 4 : Update your database schema
Simply run the following command :
$ php app/console doctrine:schema:update --force
And voilà !
panda-fire/core-bundle 适用场景与选型建议
panda-fire/core-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 188 次下载、GitHub Stars 达 2, 最近一次更新时间为 2015 年 07 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「time」 「calendar」 「task」 「organization」 「Agenda」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 panda-fire/core-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 panda-fire/core-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 panda-fire/core-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Tools to convert between .NET and PHP date formats
A modern PHP library for generating iCalendar v2.0 events
Adds the EDTF data type to Wikibase
Expose the DDev executable commands to the Robo task runner.
A powerful event calendar Tool for Laravel's Nova 5.
Date component is a set of methods to help with the manipulation of dates.
统计信息
- 总下载量: 188
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 28
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-07-09