承接 echobot/angularphp 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

echobot/angularphp

Composer 安装命令:

composer require echobot/angularphp

包简介

A cross-platform AngularJS/PHP bridge

README 文档

README

AngularPHP provides a bridge between PHP classes and AngularJS, by automatically exposing selected classes, methods & properties as AngularJS services. Calls to these exported methods are routed to the same object on the server, with the result being passed back to the caller via a promise. Every instance of an exported class is automatically converted to and from its equivalent when passing through AngularPHP.

Installation

Install via Composer:

composer require echobot/angularphp

Usage

In your project framework of choice, set up a route which passes the current request to AngularPHP and which renders the response. To assist in this, two utility classes exist which achieve this, depending on what framework you are using.

Laravel

The Echobot\AngularPHP\Endpoints\Laravel provides a Laravel-compatible endpoint, which can be easily used to create an AngularPHP endpoint on a particular route:

Echobot\AngularPHP\Endpoints\Laravel::create('/models.js')
        ->addDirectory(__DIR__ . '/models/')
        ->debug($debug);

That snippet serves up all exported classes in the models directory, from the route /models.js.

PHP

The Echobot\AngularPHP\Endpoints\PHPBuiltIn class can be used to serve requests based on the $_SERVER global variable, which includes most old frameworks and PHP's built-in command-line web server.

Other Frameworks

One can use the Echobot\AngularPHP\Endpoints\PHPBuiltIn as an example to see how the endpoint class extends the AngularPHP class in order to improve the ease of use for a given framework. Using this example, creating a new endpoint for an unsupported framework should be relatively simple.

Example

The following example defines an AngularPHP endpoint which exposes a single class (ExampleClass) in an AngularJS module called ExampleModule:

class ExampleClass
{
    /** @Export */
    public $property;
    
    /** @Export */
    public function someMethod($arg)
    {
        return 'Here is your argument: ' . $arg;
    }
}

Echobot\AngularPHP\Endpoints\PHPBuiltIn::create()
    ->setModuleName('ExampleModule')
    ->addClass('ExampleClass')
    ->run();

Echobot\AngularPHP\Endpoints\PHPBuiltIn is an endpoint which understands the standard PHP request representation ($_SERVER). An endpoint for Laravel is also included in .

IDs

AngularPHP allows the specification of one or more properties as containing the object's unique ID by adding @Id to the property's DocComment. Any object passing through AngularPHP with a known ID will return a reference to the existing object, allowing one object with a given ID to only exist once in AngularJS. For example, if you return a user twice from the backend, the second returned value will be a reference to the first, as they share an ID.

Read-Only Properties

By adding @ReadOnly to the DocComment of an exported property, the value of this property will not be passed back from the AngularJS module, and will not be updated on the specified object/class.

Inheritance

AngularPHP strives to fully respect inheritance, provided the classes in the inheritance chain are also exported.

Security

Beyond limiting access to exported methods & properties, AngularPHP leaves security entirely up to you. This is a curse and a blessing - it's won't stop you doing what you want, but it's up to you to secure it.

Caution!

This code is relatively untested. We've had a lot of success with it, but one should be prepared for unintended behaviour. Any bug fixes will be gratefully received.

echobot/angularphp 适用场景与选型建议

echobot/angularphp 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 30 次下载、GitHub Stars 达 1, 最近一次更新时间为 2015 年 07 月 22 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 echobot/angularphp 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 echobot/angularphp 我们能提供哪些服务?
定制开发 / 二次开发

基于 echobot/angularphp 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 30
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 17
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-07-22