Skip to content

Commit e6baecb

Browse files
committed
Initial entities generator
1 parent b23f5e3 commit e6baecb

File tree

586 files changed

+57735
-201
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

586 files changed

+57735
-201
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
composer.phar
2+
vendor

.travis.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
language: php
2+
3+
php:
4+
- 5.4
5+
- 5.5
6+
7+
before_script:
8+
- composer install --dev --prefer-source
9+
10+
script:
11+
- php vendor/bin/schema.php .
12+
- php vendor/bin/schema.php . vendor/dunglas/php-schema.org-model/examples/config/lechoppe.yml

LICENSE

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2014 Kévin Dunglas
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is furnished
8+
to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

README.md

+48-2
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,62 @@
22

33
Various tools to generate a data model based on [Schema.org](http://schema.org) vocables.
44

5+
*This project is a work in progress. It is not finished yet.*
6+
57
## Installation
68

9+
Use [Composer](http://getcomposer.org).
10+
11+
composer require dunglas/php-schema.org-model
12+
13+
## Doctrine entities generator
14+
15+
Generates Doctrine entities from Schema.org vocables.
16+
17+
Usage:
18+
php vendor/bin/schema.php my-output-directory/ [config.yml]
19+
20+
### Configuration
21+
22+
See [lechoppe.yml](examples/config/lechoppe.yml) file.
23+
24+
### Configuration reference
25+
26+
```yaml
27+
# Debug mode
28+
debug: false
29+
30+
# Emit a warning if a property is not derived from GoodRelations
31+
check_is_goodrelations: false
32+
33+
# A license or any text to use as header of generated files
34+
header: false # Example: // (c) Kévin Dunglas <[email protected]>
35+
36+
# The namespace of the generated files
37+
namespace: SchemaOrg # Example: SchemaOrgModel
38+
39+
# The value of the phpDoc's @author annotation
40+
author: false # Example: Kévin Dunglas <[email protected]>
41+
42+
# Visibility of entities fields
43+
field_visibility: ~ # One of "private"; "protected"; "public"
44+
45+
# Schema.org's types to use
46+
types:
47+
48+
# Prototype
49+
id:
750

51+
# Properties of this type to use
52+
properties: []
53+
```
854
9-
## Cardinality extractor
55+
## Cardinalities extractor
1056
1157
Extracts property's cardinality.
1258
[GoodRelations](http://www.heppnetz.de/projects/goodrelations/) data are used when applicable. Other cardinalities are guessed using the property's comment.
1359
When the cardinality cannot be automatically extracted, it's value is set to `unknown`.
1460

1561
Usage:
16-
php bin/console.php schema:extract-cardinality
62+
php vendor/bin/schema.php schema:extract-cardinalities
1763

bin/console.php

-15
This file was deleted.

bin/schema

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
include('schema.php');

bin/schema.php

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
/*
4+
* (c) Kévin Dunglas <[email protected]>
5+
*
6+
* This source file is subject to the MIT license that is bundled
7+
* with this source code in the file LICENSE.
8+
*/
9+
10+
require __DIR__ . '/../vendor/autoload.php';
11+
12+
use Symfony\Component\Console\Application;
13+
use SchemaOrgModel\Command\ExtractCardinalitiesCommand;
14+
use SchemaOrgModel\Command\DumpConfigurationCommand;
15+
use SchemaOrgModel\Command\GenerateEntitiesCommand;
16+
17+
define('SCHEMA_ORG_JSON_ALL_URL', 'http://schema.rdfs.org/all.json');
18+
define('GOOD_RELATIONS_OWL_URL', 'http://purl.org/goodrelations/v1.owl');
19+
20+
$application = new Application();
21+
$application->add(new ExtractCardinalitiesCommand());
22+
$application->add(new DumpConfigurationCommand());
23+
$application->add(new GenerateEntitiesCommand());
24+
$application->run();

composer.json

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "dunglas/php-schema-org-model",
2+
"name": "dunglas/php-schema.org-model",
33
"type": "library",
4-
"description": "Generate a PHP model layer from Schema.org",
4+
"description": "Various tools to generate a data model based on Schema.org vocables",
55
"keywords": ["schema.org", "model", "doctrine", "entity"],
66
"homepage": "http://dunglas.fr",
77
"license": "MIT",
@@ -21,8 +21,12 @@
2121
"ext-json": "*",
2222
"doctrine/orm": "~2.4",
2323
"symfony/console": "~2.4",
24+
"symfony/yaml": "~2.4",
25+
"symfony/config": "~2.4",
2426
"symfony/validator": "~2.4",
25-
"twig/twig": "~1.15"
26-
}
27+
"twig/twig": "~1.15",
28+
"psr/log": "~1.0"
29+
},
30+
"bin": ["bin/schema", "bin/schema.php"]
2731
}
2832

0 commit comments

Comments
 (0)