承接 ralouphie/codify 相关项目开发

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

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

ralouphie/codify

Composer 安装命令:

composer require ralouphie/codify

包简介

A simple PHP package for saving and autoloading generated PHP files.

README 文档

README

Build Status Coverage Status Latest Stable Version Latest Unstable Version License

A simple PHP package for saving and autoloading generated PHP files. It's useful when writing frameworks that generate and save code on the fly.

Usage

<?php

// Create a code store.
$store = new \Codify\Stores\Filesystem(
    'Some\\Name\\Space',
    'directory/to/save/code'
);

// Hook up code store to an autoloader and register it.
$autoloader = new \Codify\Autoloader($store);
$autoloader->register();

// Now you can save classes.
$class = 'Some\\Name\\Space\\Foo';
$store->save($class, 'namespace Some\\Name\\Space;
    class Foo {
        public function foo() { echo "foo"; }
    }
');

// And use the classes you save.
$instance = new $class;
$instance->foo(); // Outputs "foo".

Dynamic Compilation

<?php

$store = new \Codify\Stores\Filesystem(/* ... */);

// Create a compiled store that will generate code for missing classes
// under the code store's namespace.
$compiled_store = new CompiledStore($store, function ($class) {

    // Generate code.
    return $code_generated;
});

$autoloader = new \Codify\Autoloader($compiled_store);
$autoloader->register();


$missing_class = 'Some\\Name\\Space\\Bar';

// This will trigger the compiled store above.
$instance = new $missing_class;

// If the compile was successful, we can now use the object.
$instance->doSomething();

// To avoid fatal errors (compile skipped), 
// you can check if the class exists first.
if (class_exists($missing_class)) {
    // Compile was successful!
} else {
    // The compile was skipped.
}

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固