noframework/noframework 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

noframework/noframework

Composer 安装命令:

composer require noframework/noframework

包简介

Clear fast flexible lightweight php 5.5 framework

README 文档

README

(PHP 5 >= 5.5)

  • PSR-0 file autoloading
  • dependency injection
  • lazy object creation
  • magic memoization
  • hierarchical configuration
  • if no class is defined, try to guess it by namespace and property name (since we have PSR-0)
  • virtual database
  • ORM
  • only 24 not very fat classes

How to use

<?php
require __DIR__ . '/../class.php/NoFramework/Config.php';

// Read comments in Config.php for yaml examples
// example.yaml should reside in '.config' up from script path
// (i.e. '../.config' or '../../.config', and so on until found)

(new NoFramework\Config)->parse('example.yaml')->application->start();
<?php
require __DIR__ . '/../class.php/NoFramework/Autoload.php';

(new NoFramework\Autoload)->register();

(new NoFramework\Autoload([
    'namespace' => 'Example',
    'path' => __DIR__ . '/../class.php/Example',
])->register();

(new Example\Factory([

    // Object of class Example\Logger will be instantiated as property 'log'
    // in object of class Example\Service instantiated in property 'service'.
    // If Example\Service does not exist, then it will be Example\Factory

    'service.log' => ['$new' => 'Logger'],

]))->service->start();
class SomeClass
{
    use \NoFramework\Magic;

    protected $default = 'default value';

    // Memoization
    // (same as default value, but calculated)
    protected function __property_pid()
    {
        echo 'calculated' . PHP_EOL;

        return posix_getpid();
    }

    public function callMe()
    {
        var_dump($this->pid);
        var_dump($this->pid);
        var_dump($this->pid);
    }
}

Minimal HTTP application

Suppose we create project in /home/example.com

Maybe you wish to create that user, not only a directory:

useradd example.com

Copy NoFramework and Twig into /home/example.com/class.php directory:

git clone https://github.com/NoFramework/NoFramework
git clone https://github.com/fabpot/Twig

Create /home/example.com/.cache and make it writable for php-fpm user or for all

Create /home/example.com/index.php:

<?php
namespace NoFramework;

$debug = true;

ini_set('date.timezone', 'UTC');

ini_set('display_startup_errors', $debug);
ini_set('display_errors', $debug);

require __DIR__ . '/class.php/NoFramework/Autoload.php';

(new Autoload)->register();

(new Autoload([
    'namespace' => 'Twig',
    'path' => __DIR__ . '/class.php/Twig/lib/Twig',
    'separator' => '_',
]))->register();

(new Http\Application([
    'namespace' => __NAMESPACE__,
    'template' => ['$new' => [
        'class' => 'Template\Twig',
        'path' => __DIR__ . '/template',
        'cache' => __DIR__ . '/.cache/twig',
        'search_path' => 'landing',
        'auto_reload' => $debug,
        'debug' => $debug, // enable 'dump' function
    ]]
]))->start();

Edit /etc/hosts on server and set ip of example.com explicitly.

Create /home/example.com/nginx.include:

server {
    listen example.com;
    server_name www.example.com;
    return 301 $scheme://example.com$request_uri;
}

server {
    listen example.com;
    server_name example.com;
    root /home/$host;

    location = /favicon.ico {
        empty_gif;
    }

    location / {
        fastcgi_pass unix:/var/run/php5-fpm.sock; #debian default
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root/index.php;
    }
}
ln -s /home/example.com/nginx.include /etc/nginx/conf.d/example.com.conf

Put some html in:

/home/example.com/template/landing/index.html.twig

/home/example.com/template/landing/some_page.html.twig
/home/example.com/template/landing/some_dir/some_other_page.html.twig
... and so on

Restart nginx

Edit /etc/hosts on your local machine if necessary

Visit:

http://example.com/

http://example.com/some_page/
http://example.com/some_dir/some_other_page/
... and so on

noframework/noframework 适用场景与选型建议

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

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 6
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 27
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-11-05