定制 lastguest/aleph 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

lastguest/aleph

Composer 安装命令:

composer require lastguest/aleph

包简介

A simple PHP framework for very small sites

README 文档

README

![Gitter](https://badges.gitter.im/Join Chat.svg)

Latest Stable Version Latest Unstable Version License

Aleph is a very simple PHP framework for very small sites.

Installation

Install via composer:

$ composer require lastguest/aleph

Or download only the framework file

Or remote include the framework file: (needs allow_url_include = true in php.ini)

<?php
include "https://raw.githubusercontent.com/lastguest/aleph/master/src/aleph.php";

Documentation

Boostrap

Include composer vendor/autoload.php

<?php
include 'vendor/autoload.php';

or directly the aleph.php file in your front controller:

<?php
include 'aleph.php';

URL Routing

// The index route
get('/',function(){
  echo "<h1>Hello!</h1>";
});

// Listen POST on /
post('/',function(){
  echo "<h1>Received POST Data:</h1><pre>";
  print_r($_POST);
  echo "</pre>";
});

If you return an array or an object it will served as JSON

get('/api/todos',function(){
  return [
    [ "id"=>1, "text"=>"Write documentation" ],
    [ "id"=>2, "text"=>"Smile" ],
    [ "id"=>3, "text"=>"Play more games" ],
    [ "id"=>4, "text"=>"Conquer the World" ],
  ];
});

The response will be :

[
    {
        "id": 1,
        "text": "Write documentation"
    },
    {
        "id": 2,
        "text": "Smile"
    },
    {
        "id": 3,
        "text": "Play more games"
    },
    {
        "id": 4,
        "text": "Conquer the World"
    }
]

Database

Init database DSN

database('init','mysql:host=localhost;dbname=test','root','root');

Run query and get single column

$uid = sql_value('select id from users where username = ? limit 1', array($username));

Run query and get single row

$user = sql_row('select * from users where username = ?', array($username));
echo $user->email;

Run query and iterate all returned rows

sql_each('select * from users', function($user){
  echo "<li><a href="mailto:{$user->email}">{$user->name}</a></li>";
});

Passing parameters:

sql_each('select * from users where activated = ?', function($user){
  echo "<li><a href="mailto:{$user->email}">{$user->name}</a></li>";
}, array('YES'));

Exec sql command

if ( sql('delete from users where id = ?',array(123)) ) echo "User deleted.";

Service

The Service function is a small DI container.

Register a factory method

class TestService {
	public $value;
	function __construct($x){ $this->value = $x; }
}

service('test',function($x){
	return new TestService($x);
});

Make service instances

$a = service('test',3);
$b = service('test',5);
[{"value":3},{"value":5}]

Register a singleton service

service('test',function($x){
	static $instance = null;
	return $instance === null ? $instance = new TestService($x) : $instance;
});

Now if we call multiple times the service('test') function we got the singleton instance every time :

$a = service('test',3);
$b = service('test',5);
$c = service('test');
[{"value":3},{"value":3},{"value":3}]

======================

Contributing

How to get involved:

  1. Star the project!
  2. Answer questions that come through GitHub issues
  3. Report a bug that you find

Core follows the GitFlow branching model. The master branch always reflects a production-ready state while the latest development is taking place in the develop branch.

Each time you want to work on a fix or a new feature, create a new branch based on the develop branch: git checkout -b BRANCH_NAME develop. Only pull requests to the develop branch will be merged.

Pull requests are highly appreciated.

Solve a problem. Features are great, but even better is cleaning-up and fixing issues in the code that you discover.

Versioning

Core is maintained by using the Semantic Versioning Specification (SemVer).

Copyright and license

Copyright 2014 Stefano Azzolini under the MIT license.

Bitdeli Badge

lastguest/aleph 适用场景与选型建议

lastguest/aleph 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 23 次下载、GitHub Stars 达 16, 最近一次更新时间为 2014 年 12 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「framework」 「fast」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 23
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 16
  • 点击次数: 14
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 16
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-12-04