承接 memio/model 相关项目开发

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

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

memio/model

最新稳定版本:3.0.1

Composer 安装命令:

composer require memio/model

包简介

Memio's models, used to describe the code to generate

README 文档

README

Describe PHP code (classes/interfaces with their constants, properties, methods, method arguments and even PHPdoc) by constructing "Model" objects.

Note: This package is part of Memio, a highly opinionated PHP code generator. Have a look at the main repository.

Installation

Install it using Composer:

composer require memio/model:^3.0 

Example

Let's say we want to describe the following method:

 /**  * @api  */ public function doSomething(ValueObject $valueObject, int $type = self::TYPE_ONE, bool $option = true);

In order to do so, we'd need to write the following:

<?php require __DIR__.'/vendor/autoload.php'; use Memio\Model\Argument; use Memio\Model\Method; use Memio\Model\Phpdoc\ApiTag; use Memio\Model\Phpdoc\MethodPhpdoc; use Memio\Model\Phpdoc\ParameterTag; $method = (new Method('doSomething')) ->setPhpdoc((new MethodPhpdoc()) ->addParameterTag(new ParameterTag('Vendor\Project\ValueObject', 'valueObject')) ->addParameterTag(new ParameterTag('int', 'type')) ->addParameterTag(new ParameterTag('bool', 'option')) ->addApiTag(new ApiTag()) ) ->addArgument(new Argument('Vendor\Project\ValueObject', 'valueObject')) ->addArgument((new Argument('int', 'type')) ->setDefaultValue('self::TYPE_ONE') ) ->addArgument((new Argument('bool', 'option')) ->setDefaultValue('true') ) ;

Usually models aren't described manually like this, they would be built dynamically:

// Let's say we've received the following two parameters: $methodName = 'doSomething'; $arguments = [new \Vendor\Project\ValueObject(), ValueObject::TYPE_ONE, true]; $method = new Method($methodName); $phpdoc = (new MethodPhpdoc())->setApiTag(new ApiTag()); $index = 1; foreach ($arguments as $rawArgument) { $type = is_object($rawArgument) ? get_class($argument) : gettype($rawArgument); $name = 'argument'.$index++; $argument = new Argument($type, $name); $method->addArgument($argument); $phpdoc->addParameterTag(new ParameterTag($type, $name)); } $method->setPhpdoc($phpdoc);

We can build dynamically the models using a configuration file, user input, existing source code... Possibilities are endless!

Once built these models can be further tweaked, and converted to another format: an array, source code, etc... Again, the possibilities are endless!

Have a look at the main respository to discover the full power of Medio.

Want to know more?

Memio uses phpspec, which means the tests also provide the documentation. Not convinced? Then clone this repository and run the following commands:

composer install ./vendor/bin/phpspec run -n -f pretty 

You can see the current and past versions using one of the following:

And finally some meta documentation:

Roadmap

  • get rid of Type
  • extract Import (use statement) from FullyQualifiedName
  • get rid of FullyQualifiedName
  • support more PHPdoc stuff
  • support annotations

统计信息

  • 总下载量: 311.13k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 1
  • 依赖项目数: 8
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 1
  • Forks: 7
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固