fourcoders/latch-bundle
Composer 安装命令:
composer require fourcoders/latch-bundle
包简介
Easy integration of Latch in your symfony2 project.
README 文档
README
LatchBundle
Easy integration of Latch in your symfony2 project. You can visit the official website: http://fourcoders.github.io/LatchBundle/
Prerequisites
Translations
If you wish to use default texts provided in this bundle, you have to make sure you have translator enabled in your config.
# app/config/config.yml framework: translator: ~
For more information about translations, check Symfony documentation.
Installation
- Download LatchBundle using composer
- Enable the Bundle
- Update your User class
- Configure the LatchBundle
- Import LatchBundle routing
- Update your database schema
- Setup your latch operations
Step 1: Download LatchBundle using composer
Add LatchBundle in your composer.json.
First option: You can install the official Latch PHP SDK by ElevenPaths. Composer can not load repositories recursively .You need to add this dependency in your composer.json or You can manage it by satis or toran proxy.
{ "repositories": [ { "type": "package", "package": { "name": "elevenpaths/latch-sdk-php", "version": "dev-master", "source": { "url": "https://github.com/ElevenPaths/latch-sdk-php.git", "type": "git", "reference": "origin/master" }, "autoload": { "classmap": ["/"] } } } ], "require": { "elevenPaths/latch-sdk-php": "dev-master", "fourcoders/latch-bundle": "dev-master" } }
After install libraries, You must put eleven_paths as a your latch_driver in your config.yml:
# app/config/config.yml fourcoders_latch: latch_app_id: PdHF10WnSDasSINHHZd0n latch_app_secret: kH1oqtVlWyWZLKQWIJCAKLodd4XUIgMMLQiwag latch_driver: eleven_paths latch_redirect: / latch_operations: ~
Second Option: You can install unofficial fourcoders/latch-sdk-php. Its very similar to the official Latch PHP SDK by ElevenPaths , however we use composer for managing the dependencies and Guzzle for the HTTP Request.
{ "require": { "fourcoders/latch-sdk-php": "dev-master", "fourcoders/latch-bundle": "dev-master" } }
After install libraries, You must put fourcorders as a your latch_driver in your config.yml:
# app/config/config.yml fourcoders_latch: latch_app_id: PdHF10WnSDasSINHHZd0n latch_app_secret: kH1oqtVlWyWZLKQWIJCAKLodd4XUIgMMLQiwag latch_driver: fourcoders latch_redirect: / latch_operations: ~
Step 2: Enable the bundle
Enable the bundle in the kernel:
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Fourcoders\Bundle\LatchBundle\FourcodersLatchBundle(), ); }
Step 3: Update your User class
Insert a new field in the User entity, or whatever you are using with your security provider.
If you are using FOSUserBundle this a example:
<?php // src/Acme/UserBundle/Entity/User.php namespace Acme\UserBundle\Entity; use FOS\UserBundle\Model\User as BaseUser; use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity * @ORM\Table(name="user") */ class User extends BaseUser { /** * @ORM\Id * @ORM\Column(type="integer") * @ORM\GeneratedValue(strategy="AUTO") */ protected $id; /* Start of the new field */ /** * @var string $latch * * @ORM\Column(name="latch", type="string", length=255, nullable=true) */ private $latch; /** * Set latch * * @param string $latch */ public function setLatch($latch) { $this->latch = $latch; } /** * Get latch * * @return string */ public function getlatch() { return $this->latch; } /* End of the new field */ public function __construct() { parent::__construct(); // your own logic } }
For a stardard register, check Symfony documentation, after you can override the User.php.
<?php // src/Acme/AccountBundle/Entity/User.php namespace Acme\AccountBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as Assert; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; /** * @ORM\Entity * @UniqueEntity(fields="email", message="Email already taken") */ class User { /** * @ORM\Id * @ORM\Column(type="integer") * @ORM\GeneratedValue(strategy="AUTO") */ protected $id; /** * @ORM\Column(type="string", length=255) * @Assert\NotBlank() * @Assert\Email() */ protected $email; /** * @ORM\Column(type="string", length=255) * @Assert\NotBlank() * @Assert\Length(max = 4096) */ protected $plainPassword; public function getId() { return $this->id; } public function getEmail() { return $this->email; } public function setEmail($email) { $this->email = $email; } public function getPlainPassword() { return $this->plainPassword; } public function setPlainPassword($password) { $this->plainPassword = $password; } /* Start of the new field */ /** * @ORM\Column(name="latch", type="string", length=255, nullable=true) */ private $latch; public function setLatch($latch) { $this->latch = $latch; } public function getlatch() { return $this->latch; } /* End of the new field */ }
Step 4: Configure the LatchBundle
How to setup latch_driver
# app/config/config.yml fourcoders_latch: latch_app_id: PdHF10WnSDasSINHHZd0n latch_app_secret: kH1oqtVlWyWZLKQWIJCAKLodd4XUIgMMLQiwag latch_driver: eleven_paths latch_redirect: / latch_operations: ~
Step 5: Import LatchBundle routing files
# app/config/routing.yml fourcoders_latch: resource: "@FourcodersLatchBundle/Resources/config/routing.yml" prefix: /
Step 6: Update your database schema
For ORM run the following command.
$ php app/console doctrine:schema:update --force
Step 7: Setup your latch operations
You can securize any http resource with your Latch operations. Begin the setup process of your operations with your operation name and pattern in the config.yml
# app/config/config.yml fourcoders_latch: latch_app_id: PdHF10WnSDasSINHHZd0n latch_app_secret: kH1oqtVlWyWZLKQWIJCAKLodd4XUIgMMLQiwag latch_driver: eleven_paths latch_redirect: / latch_operations: operation1: pattern: "/profile" latch_operation : "profile-operation" operation2: pattern: "/transfer" latch_operation: "transfer-operation"
Finally your operations must be defined in the access control params:
# app/config/security.yml access_control: - { path: ^/transfer$, role: ROLE_USER } - { path: ^/profile$, role: ROLE_USER }
Now that you have completed the basic installation and configuration of the LatchBundle, you are ready to learn about more advanced features and usages of the bundle.
The following documents are available:
fourcoders/latch-bundle 适用场景与选型建议
fourcoders/latch-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 242 次下载、GitHub Stars 达 10, 最近一次更新时间为 2014 年 03 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「symfony」 「php」 「security」 「latch」 「fourcoders」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 fourcoders/latch-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 fourcoders/latch-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 fourcoders/latch-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The bundle for easy using json-rpc api on your project
Provide a way to secure accesses to all routes of an symfony application.
It's a barebone security class written on PHP
Bundle Symfony DaplosBundle
Contao CMS integrity check for some files
A PHP security linter to detect insecure functions like var_dump, print_r, and other dangerous functions in your codebase
统计信息
- 总下载量: 242
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 12
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-03-23