Download the PHP package popo/generator without Composer

On this page you can find all versions of the php package popo/generator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package generator

POPO

Build and run tests

POPO - "Plain Old Php Object" was inspired by "Plain Old Java Object" (POJO) concept.

POPO generator can also locate, load, validate, and combine schemas to create PHP source code files, representing Arrays / Data Structures / Data Transfer Objects / Doctrine ORM Entities / MongoDB ODM Documents.

POPO Schema can be defined and extended on few levels, and it can be defined in multiple files.

Examples

Single schema file

Simple schema in YAML format, describing properties and relations of POPO objects.

Multiple schema files

The same example can be split into multiple files. However, this time, it's the Bar that modifies the Foo definition.

The generated code is the same, but the schema dependencies are inverted.

In both cases, Foo object uses Bar object as its dependency, and they are both defined under Example schema name.

Generated code usage examples

Instantiate data structure from an array.

Output:

Display hierarchy of objects as an array.

Output:

Run bin/popo generate -s tests/fixtures/popo-readme.yml or docker-popo generate -s tests/fixtures/popo-readme.yml to generate files from this example.

Installation

Note: The installation can be skipped when using docker, see Docker support section.

Usage

You can either use it as composer dependency or as docker command.

  1. Define schema file, see tests/fixtures for examples.

  2. Generate POPO files, run:

    • with composer

    • with docker

For example: bin/popo generate -s tests/fixtures/popo.yml or docker-popo generate -s tests/fixtures/popo.yml.

POPO Schema

POPO Schema can be defined and extended on few levels- and it can be defined in multiple files.

The schema supports key mapping- inheritance- collections and encapsulation of other POPO objects.

Schema Definition

Schema configuration options

namespace

Defines generated class namespace.

outputPath

Defines output directory.

namespaceRoot

Defines the begging of outputPath that should be removed. For example to generated files under src/Example with App\Example namespace.

extend

Which class should the generated class extend from. Must start with \ or contain ::class.

implement

Which interface should the generated class implement. Must start with \ or contain ::class.

comment

Class comment.

phpComment

Generated PHP file comment.

use

Import statements.

trait

Traits statements.

attribute

Class attributes value.

attributes: array

Attribute value as collection. Supported values:

classPluginCollection: array

Additional plugins used to generate methods.

namespacePluginCollection: array

Additional plugins used to generate namespace block.

propertyPluginCollection: array

Additional plugins used to generate properties.

mappingPolicyPluginCollection: array

Set of plugins used to map property names, e.g. fooId => FOO_ID.

Property configuration options

name

The name of the property. The property related methods will be generated based on this value. For example getFooBar(). This is required parameter.

type

Property data type, supported are:

Default property type is string.

comment

Docblock value for property and methods.

default: mixed

Default value.

extra: array

Used by datetime data type. Supported values:

itemType

Used by array data type together with itemName element. Describes type of single array element.

itemName

Used by array data type. Describes name of single array element. For example: setProducts(array $products), addProduct(Product $item).

attribute

Attribute value.

attributes: array

Attribute value as collection. Supported values:

mappingPolicy: array

Dynamically remaps property names, for example, fooId => FOO_ID. Supported values:

mappingPolicyValue

Statically remaps property names, for example, fooId => FOO_ID.

Schema Inheritance

The popo-config values override schema-file-config values- and schema-file-config values overwrite schema-config values.

On top of that there is a global-config that is defined when using --schemaConfigFilename parameter.

schema-config

The configuration was defined as a Schema property. It will be used by all POPO objects in all files under given schema.

schema-file-config

The configuration was defined as a SchemaFile property. It will be used by all POPO objects in current file.

popo-config

The configuration was defined as a POPO property. It will be used by one specific POPO objects in current file.

See tests/fixtures for schema examples.

Property name remapping

POPO can remap property keys names, for example change foo_id into fooId.

See Property Name Remapping doc.

Pluggable architecture

New functionality can be provided on the command line, or via configuration.

See Plugins doc.

Doctrine Support

See Doctrine Support doc.

Command line options

See Command Line Options doc.

More Examples

See tests for more usage examples.

Composer script

Add popo scrip to composer and run composer popo in a project.

Docker support

With docker you can generate files without installing POPO as dependency in the project.

You can either run the command directly, or create an alias, e.g.:

For example:

See also: bin/docker-popo.

PHP version compatibility

POPO schema example

Schema example that produces generated PopoConfigurator class.


All versions of generator with dependencies

PHP Build Version
Package Version
Requires php Version ^8
ext-ctype Version *
symfony/finder Version ^5|^6
symfony/console Version ^5|^6
symfony/yaml Version ^5|^6
nette/php-generator Version ^4
symfony/config Version ^5|^6
symfony/dependency-injection Version ^5|^6
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package popo/generator contains the following files

Loading the files please wait ....