kami/booking-bundle
Composer 安装命令:
composer require kami/booking-bundle
包简介
Adds some booking functionality to your Symfony project
README 文档
README
Booking Bundle for Symfony 2 Applications. Bundle provides some useful functionality for handling bookings on your website.
Installation
1. Download
Prefered way to install this bundle is using composer
Download the bundle:
$ php composer.phar require "kami/booking-bundle"
2. Add it to your Kernel:
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Kami\BookingBundle\KamiBookingBundle(), ); }
3. Create your entity
Doctrine ORM
Bundle has all necessary mappings for your entity. Just create your entity class and extend it from
Kami\BookingBundle\Entity\Booking, create your id field and setup proper relation for
item you want to be booked.
<?php namespace Vendor\Bundle\Entity; use Kami\BookingBundle\Entity\Booking as BaseClass; /** * Booking * * @ORM\Entity() * @ORM\Table(name="booking") */ class Booking extends BaseClass { /** * @var integer * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ protected $id; /** * @var \Vendor\Bundle\Entity\BookableItem * * @ORM\ManyToOne(targetEntity="BookableItem", inversedBy="bookings") * @ORM\JoinColumn(name="property_id", referencedColumnName="id") */ protected $item; // Don't forget about getters and setters }
Now we are ready to rock!
Booker Service
Core component of this bundle is booker service. You can get it in your controller by using
<?php public function bookingAction() { $this->get('booker'); /** @var \Kami\BookingBundle\Helper\Booker */ }
Booker Service has following methods:
isAvailableForPeriod($item, \DateTime $start, \DateTime $end) Checks is your item available for period,
returns boolean
isAvailableForDate($item, \DateTime $date) Checks is your item available for date, returns boolean
whereAvailableForPeriod(QueryBuilder $queryBuilder, $join, \DateTime $start, \DateTime $end) Updates your
QueryBuilder and returns the same QueryBuilder object with added join and where clause.
Note:
$joinisarray('field', 'alias')
whereAvailableForDate(QueryBuilder $queryBuilder, $join, \DateTime $date) Updates your
QueryBuilder and returns the same QueryBuilder object with added join and where clause.
Note:
$joinisarray('field', 'alias')
book($item, \DateTime $start, \DateTime $end) Books your item returns Entity | false (Entity
on success, false on failure)
Calendar Twig Extension
Bundle also provides cool Twig extension. To use it in your template just try following:
{{ kami_booking_calendar(item, "now", 4) }}
Where
item - is object of your bookable item
now - is any date allowed for \DateTime::__construct()
4 - number of months to be rendered after desired date
Overriding template
Template can be overridden as usual in Symfony application. Just create following directory structure:
app/Resources/views/KamiBookingBundle/Calendar/month.html.twig
kami/booking-bundle 适用场景与选型建议
kami/booking-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 629 次下载、GitHub Stars 达 9, 最近一次更新时间为 2017 年 02 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「calendar」 「booking」 「availability」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 kami/booking-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 kami/booking-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 kami/booking-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Library to handel intervals
A modern PHP library for generating iCalendar v2.0 events
The easiest way to determine calendar availability using Carbon.
A powerful event calendar Tool for Laravel's Nova 5.
Check for holidays - localeaware
This TYPO3 distribution provides a sample website using bootstrap and the extensions pizpalue and container_elements. The distribution tailors Swiss market featuring German as default language and additional translations to French, English and Finnish.
统计信息
- 总下载量: 629
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 9
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-02-03