gnugat / medio
v2.0.1
2020-03-17 10:32 UTC
Requires
- php: ^7.0
- memio/linter: ^2.0@alpha
- memio/model: ^2.0@alpha
- memio/pretty-printer: ^2.0@alpha
- memio/twig-template-engine: dev-twig3 as 2.0.x-dev
- memio/validator: ^2.0@alpha
Requires (Dev)
- friendsofphp/php-cs-fixer: ^1.6
- phpunit/phpunit: ^5.4
- dev-master
- v2.0.1
- v2.0.0
- v2.0.0-alpha3
- v2.0.0-alpha2
- v1.1.1
- v1.1.0
- v1.0.1
- v1.0.0
- v1.0.0-rc14
- v1.0.0-rc13
- v1.0.0-rc12
- v1.0.0-rc11
- v1.0.0-rc10
- v1.0.0-rc9
- v1.0.0-rc8
- v1.0.0-rc7
- v1.0.0-rc6
- v1.0.0-rc5
- v1.0.0-rc3
- v1.0.0-rc2
- v1.0.0-rc1
- v1.0.0-beta4
- v1.0.0-beta3
- v1.0.0-beta2
- v1.0.0-beta1
- v1.0.0-alpha18
- v1.0.0-alpha17
- v1.0.0-alpha16
- v1.0.0-alpha15
- v1.0.0-alpha14
- v1.0.0-alpha13
- v1.0.0-alpha12
- v1.0.0-alpha11
- v1.0.0-alpha10
- v1.0.0-alpha9
- v1.0.0-alpha8
- v1.0.0-alpha7
- v1.0.0-alpha6
- v1.0.0-alpha5
- v1.0.0-alpha4
- v1.0.0-alpha3
- v1.0.0-alpha2
- v1.0.0-alpha1
- v0.4.0
- v0.3.0
- v0.2.0
- v0.1.0
- dev-version-2
This package is not auto-updated.
Last update: 2022-02-01 12:40:20 UTC
README
Memio是一个库,它允许您通过构建“模型”类(例如 new Method('__construct')
)来描述PHP代码,然后使用PrettyPrinter
生成它!
注意:实际的生成逻辑存储在Twig模板中。如果提供的编码风格不符合您的喜好,您可以轻松地覆盖这些模板。
安装
使用Composer安装
composer require memio/memio:^1.0
完整示例
我们将生成一个具有构造函数和两个属性的类
<?php require __DIR__.'/vendor/autoload.php'; use Memio\Memio\Config\Build; use Memio\Model\File; use Memio\Model\Object; use Memio\Model\Property; use Memio\Model\Method; use Memio\Model\Argument; // Describe the code you want to generate using "Models" $file = File::make('src/Vendor/Project/MyService.php') ->setStructure( Object::make('Vendor\Project\MyService') ->addProperty(new Property('createdAt')) ->addProperty(new Property('filename')) ->addMethod( Method::make('__construct') ->addArgument(new Argument('DateTime', 'createdAt')) ->addArgument(new Argument('string', 'filename')) ) ) ; // Generate the code and display in the console $prettyPrinter = Build::prettyPrinter(); $generatedCode = $prettyPrinter->generateCode($file); echo $generatedCode; // Or display it in a browser // echo '<pre>'.htmlspecialchars($prettyPrinter->generateCode($file)).'</pre>';
在这个简单的示例中,我们得到以下输出
<?php namespace Vendor\Project; class MyService { private $createdAt; private $filename; public function __construct(DateTime $createdAt, $filename) { } }
想了解更多吗?
Memio非常强大,通过阅读文档来发现如何使用它
您可以使用以下方式查看当前和过去的版本:
git tag
命令- Github上的发布页面
- 列出版本之间变化的文件
最后是一些元文档
路线图
- 命令(例如添加使用语句、添加PHPdoc、注入依赖等)
- 解析现有代码(使用nikic的PHP-Parser)