intracto/smartcode-bundle
Composer 安装命令:
composer require intracto/smartcode-bundle
包简介
This bundle provides a way to generate software licenses with Symfony
README 文档
README
If you use this bundle, contact @tvlooy about ownership.
SmartCodeBundle

This bundle provides a way to generate software licenses for a given payload.
It has been inspired by the Promotion Bundle of Sylius.
How to install?
Install the bundle via composer
composer require intracto/smartcode-bundle
Enable the bundle
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
// ...
public function registerBundles()
{
$bundles = array(
// ...,
new Intracto\SmartCodeBundle\SmartCodeBundle(),
);
// ...
}
}
How to run tests?
php bin/phpunit
How to get started?
Smart codes have to be bound to a payload this can be done by implementing the PayloadInterface.
use Intracto\SmartCodeBundle\Entity\PayloadInterface;
use Intracto\SmartCodeBundle\Entity\SmartCodeInterface;
class Payload implements PayloadInterface
{
...
/**
* @ORM\OneToMany(targetEntity="Intracto\SmartCodeBundle\Entity\SmartCodeInterface", mappedBy="payload")
*
* @var SmartCodes[]|ArrayCollection
*/
protected $smartCodes;
...
}
Now you can get started with the generation. To generate Smart codes you can use the SmartCodeGenerator or create your own by implementing the SmartCodeGeneratorInterface.
This service will allow you to call the function:
public function generate(PayloadInterface $payload, SmartCodeOptions $options)
As you can see this has 2 parameters, the first is your payload that you created in step 1 and the 2nd is a model containing all your options.
class SmartCodeOptions
{
protected $amount;
protected $usageLimit;
protected $expiresAt;
protected $startsAt;
protected $batch;
...
}
- Amount: The amount of smart codes you wish to generate for the given payload.
- UsageLimit: The amount of times a smart code can be used.
- ExpiresAt: The expiry date for a smart code.
- StartsAt: The date a smart code can start being used.
- Batch: A name or description you want to give the current generation.
The last thing you would probably want to do is to be able to use these smart codes you just generated. This is possible via the SmartCodeAction service, which you can also overwrite by implementing the SmartCodeActionInterface.
This class has 2 required functions:
public function register(SubjectInterface $subject, SmartCodeInterface $smartCode);
public function unregister(SubjectInterface $subject, SmartCodeInterface $smartCode);
To register or unregister a certain smart code you would need a subject that is going to be using this code. To make such a subject you can implement the SubjectInterface.
use Intracto\SmartCodeBundle\Entity\SmartCodeInterface;
use Intracto\SmartCodeBundle\Entity\SubjectInterface;
class User implements SubjectInterface
{
...
/**
* @ORM\ManyToMany(targetEntity="Intracto\SmartCodeBundle\Entity\SmartCodeInterface", inversedBy="subjects")
* @ORM\JoinTable(name="user_smartcode",
* joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="smartcode_id", referencedColumnName="id")}
* )
*
* @var SmartCode[]|ArrayCollection
*/
protected $smartCodes;
...
}
intracto/smartcode-bundle 适用场景与选型建议
intracto/smartcode-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.22k 次下载、GitHub Stars 达 4, 最近一次更新时间为 2015 年 05 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「generate」 「software」 「licenses」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 intracto/smartcode-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 intracto/smartcode-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 intracto/smartcode-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A utility to generate a Licenses file containing the full license text for every dependency in your project for legal purposes.
License management plugin for Composer
A utility to generate a Licenses file containing the full license text for every dependency in your project for legal purposes.
Powertools for much lazy with Laminas because I hate writing Controllers, Forms, InputFilters, their Factories, and you hate writing all that stuff too.
Laravel API documentation generating tool
Licenses Module for MyAdmin
统计信息
- 总下载量: 3.22k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 13
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-05-05