Skip to content

Commit

Permalink
added docker support, cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
oliwierptak committed Nov 12, 2021
1 parent 91d197e commit a55e7bf
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 19 deletions.
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM php:8-cli

RUN apt-get upgrade -y && apt-get update \
&& apt-get install -y \
wget \
zip \
unzip


RUN curl -sS https://getcomposer.org/installer | php \
&& mv composer.phar /usr/local/bin/composer \
&& cd /tmp && wget -c https://github.com/phrase/phraseapp-client/releases/download/1.13.0/phraseapp_linux_386 \
&& mv /tmp/phraseapp_linux_386 /usr/local/bin/phraseapp \
&& chmod +x /usr/local/bin/phraseapp

RUN composer self-update


ADD ./ /popo/
RUN rm -rf /popo/tests/logs/coverage/
RUN rm -rf /popo/tests/logs/coverage.xml
RUN rm -rf /popo/tests/App/Example/
RUN rm -rf /popo/tests/AppRedefinedNamespace/Example/
RUN rm -rf /popo/tests/AppWithNamespaceRoot/Example/

WORKDIR /popo
72 changes: 56 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The schema supports inheritance, collections and encapsulation of other POPO obj

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

In this case, `Foo` defines `Bar` as its property.
In this case, `Foo` defines `Bar` as its property, and they are both defined under `Example` schema name.

```yaml
$:
Expand Down Expand Up @@ -79,7 +79,7 @@ Output:
];
```

_Run `bin/popo generate -s tests/fixtures/popo-readme.yml` to generate files from this example._
_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._

### getter vs requester

Expand All @@ -92,24 +92,41 @@ method `getBar()` simply returns Bar's property value.
composer require popo/generator --dev
```

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.

### Generate command

1. Define schema file, see [tests/fixtures](tests/fixtures/) for examples.

2. Generate POPO files, run:

```sh
vendor/bin/popo generate -s <schema-path> \
-c [schema-config-filename] \
-o [output-path] \
-nm [namespace] \
-nr [namespace-root] \
-p [schema-path-filter]
```

_For example: `bin/popo generate -s tests/fixtures/popo.yml`_
- with composer

```sh
vendor/bin/popo generate -s <schema-path> \
-c [schema-config-filename] \
-o [output-path] \
-nm [namespace] \
-nr [namespace-root] \
-p [schema-path-filter]
```
- with docker
```sh
docker-popo generate -s <schema-path> \
-c [schema-config-filename] \
-o [output-path] \
-nm [namespace] \
-nr [namespace-root] \
-p [schema-path-filter]
```


_For example: `bin/popo generate -s tests/fixtures/popo.yml` or `docker-popo generate -s tests/fixtures/popo.yml`._

## Command line arguments

### `<schema-path>`

Expand Down Expand Up @@ -166,7 +183,7 @@ Each schema folder can contain multiple schema files, for example:
|-- global.config.yml
```
_Run `bin/popo generate -s tests/fixtures/ -p bundles -c tests/fixtures/bundles/project.config.yml ` to generate files from this example._
_Run `bin/popo generate -s tests/fixtures/ -p bundles -c tests/fixtures/bundles/project.config.yml` or `docker-popo generate -s tests/fixtures/ -p bundles -c tests/fixtures/bundles/project.config.yml` to generate files from this example._
### Report Command
Expand All @@ -189,7 +206,7 @@ title
popo-config Example::Foo - tests/fixtures/popo-readme.yml
```

_Run `bin/popo report -s tests/fixtures/popo-readme.yml` to generate files from this example._
_Run `bin/popo report -s tests/fixtures/popo-readme.yml` or `docker-popo report -s tests/fixtures/popo-readme.yml` to generate files from this example._


## POPO Schema
Expand Down Expand Up @@ -334,10 +351,33 @@ Add popo scrip to composer and run `composer popo` in a project.
```
"scripts": {
"popo": [
"vendor/bin/popo generate -s <schema-path>"
"bin/popo generate -s <schema-path>"
]
},
"scripts-descriptions": {
"popo": "Generate POPO files"
}
```

### Docker support

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

```
docker container run -it --rm -v "$(pwd):/app/" -w/app oliwierptak/popo bin/popo
```

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

```
alias docker-popo='docker container run -it --rm -v "$(pwd):/app/" -w/app oliwierptak/popo bin/popo ${@}'
```

For example:

```
docker-popo generate -s tests/fixtures/popo.yml
docker-popo report -s tests/fixtures/popo.yml
```

See also: [bin/docker-popo](bin/docker-popo).
1 change: 1 addition & 0 deletions bin/docker-popo
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker container run -it --rm -v "$(pwd):/app/" -w/app oliwierptak/popo bin/popo ${@}
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "popo/generator",
"description": "Plain Old PHP Object (POPO) / Data Class / Data Transfer Object (DTO) Generator. Convert JSON schema to PHP class.",
"description": "Plain Old PHP Object (POPO) / Data Structure / Data Transfer Object (DTO) Generator. Convert YAML schema to PHP class.",
"license": "MIT",
"type": "library",
"authors": [
Expand All @@ -12,7 +12,6 @@
"prefer-stable": true,
"require": {
"php": "^8",
"ext-json": "*",
"ext-ctype": "*",
"symfony/finder": "^5",
"symfony/console": "^5",
Expand All @@ -38,7 +37,8 @@
},
"scripts": {
"post-autoload-dump": [
"chmod +x bin/popo"
"chmod +x bin/popo",
"chmod +x bin/docker-popo"
],
"test": [
"vendor/bin/phpunit --no-coverage --testdox --testsuite functional,unit"
Expand Down

0 comments on commit a55e7bf

Please sign in to comment.