diff --git a/examples/.gitignore b/examples/.gitignore index ce373e9..3856918 100644 --- a/examples/.gitignore +++ b/examples/.gitignore @@ -1,2 +1,3 @@ vendor -model \ No newline at end of file +model +log diff --git a/examples/composer.json b/examples/composer.json deleted file mode 100644 index 6e55c31..0000000 --- a/examples/composer.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "require": { - "contributte/nextras-orm-generator": "^0.3" - } -} diff --git a/examples/composer.lock b/examples/composer.lock deleted file mode 100644 index 9e7f92e..0000000 --- a/examples/composer.lock +++ /dev/null @@ -1,506 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", - "This file is @generated automatically" - ], - "content-hash": "3bdc10ef774e11e3db3b29f4083495f0", - "packages": [ - { - "name": "contributte/nextras-orm-generator", - "version": "v0.3", - "source": { - "type": "git", - "url": "https://github.com/contributte/nextras-orm-generator.git", - "reference": "61af2c272d4197816610f3e117a019faf31e3729" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/contributte/nextras-orm-generator/zipball/61af2c272d4197816610f3e117a019faf31e3729", - "reference": "61af2c272d4197816610f3e117a019faf31e3729", - "shasum": "" - }, - "require": { - "doctrine/inflector": "^1.0", - "nette/database": "^2.4.0|^3.0.0.", - "nette/php-generator": "^2.5|^3.1", - "nette/utils": "^2.4|^3.0", - "php": ">=7.2" - }, - "require-dev": { - "nette/tester": "^2.0", - "ninjify/qa": "^0.8.0", - "tracy/tracy": "^2.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "0.4.x-dev" - } - }, - "autoload": { - "psr-4": { - "Contributte\\Nextras\\Orm\\Generator\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Milan Felix Sulc", - "homepage": "https://f3l1x.io" - } - ], - "description": "Nextras ORM Generator", - "homepage": "https://github.com/contributte/nextras-orm-generator", - "time": "2020-07-26T17:07:09+00:00" - }, - { - "name": "doctrine/inflector", - "version": "1.4.3", - "source": { - "type": "git", - "url": "https://github.com/doctrine/inflector.git", - "reference": "4650c8b30c753a76bf44fb2ed00117d6f367490c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/inflector/zipball/4650c8b30c753a76bf44fb2ed00117d6f367490c", - "reference": "4650c8b30c753a76bf44fb2ed00117d6f367490c", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0" - }, - "require-dev": { - "doctrine/coding-standard": "^7.0", - "phpstan/phpstan": "^0.11", - "phpstan/phpstan-phpunit": "^0.11", - "phpstan/phpstan-strict-rules": "^0.11", - "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Doctrine\\Common\\Inflector\\": "lib/Doctrine/Common/Inflector", - "Doctrine\\Inflector\\": "lib/Doctrine/Inflector" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com" - }, - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de" - }, - { - "name": "Jonathan Wage", - "email": "jonwage@gmail.com" - }, - { - "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com" - } - ], - "description": "PHP Doctrine Inflector is a small library that can perform string manipulations with regard to upper/lowercase and singular/plural forms of words.", - "homepage": "https://www.doctrine-project.org/projects/inflector.html", - "keywords": [ - "inflection", - "inflector", - "lowercase", - "manipulation", - "php", - "plural", - "singular", - "strings", - "uppercase", - "words" - ], - "funding": [ - { - "url": "https://www.doctrine-project.org/sponsorship.html", - "type": "custom" - }, - { - "url": "https://www.patreon.com/phpdoctrine", - "type": "patreon" - }, - { - "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finflector", - "type": "tidelift" - } - ], - "time": "2020-05-29T07:19:59+00:00" - }, - { - "name": "nette/caching", - "version": "v3.0.1", - "source": { - "type": "git", - "url": "https://github.com/nette/caching.git", - "reference": "b9ecbf920f240bd1ab14900d9a77876924ad7fb4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/nette/caching/zipball/b9ecbf920f240bd1ab14900d9a77876924ad7fb4", - "reference": "b9ecbf920f240bd1ab14900d9a77876924ad7fb4", - "shasum": "" - }, - "require": { - "nette/finder": "^2.4 || ^3.0", - "nette/utils": "^2.4 || ^3.0", - "php": ">=7.1" - }, - "require-dev": { - "latte/latte": "^2.4", - "nette/di": "^v3.0", - "nette/tester": "^2.0", - "tracy/tracy": "^2.4" - }, - "suggest": { - "ext-pdo_sqlite": "to use SQLiteStorage or SQLiteJournal" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause", - "GPL-2.0", - "GPL-3.0" - ], - "authors": [ - { - "name": "David Grudl", - "homepage": "https://davidgrudl.com" - }, - { - "name": "Nette Community", - "homepage": "https://nette.org/contributors" - } - ], - "description": "⏱ Nette Caching: library with easy-to-use API and many cache backends.", - "homepage": "https://nette.org", - "keywords": [ - "cache", - "journal", - "memcached", - "nette", - "sqlite" - ], - "time": "2019-11-19T18:41:40+00:00" - }, - { - "name": "nette/database", - "version": "v3.0.6", - "source": { - "type": "git", - "url": "https://github.com/nette/database.git", - "reference": "daccbd526f74311549e5c81d3181fc74f87c6733" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/nette/database/zipball/daccbd526f74311549e5c81d3181fc74f87c6733", - "reference": "daccbd526f74311549e5c81d3181fc74f87c6733", - "shasum": "" - }, - "require": { - "ext-pdo": "*", - "nette/caching": "^3.0", - "nette/utils": "^3.1", - "php": ">=7.1" - }, - "conflict": { - "nette/di": "<3.0-stable" - }, - "require-dev": { - "mockery/mockery": "^1.0.0", - "nette/di": "^v3.0", - "nette/tester": "^2.0", - "phpstan/phpstan-nette": "^0.12", - "tracy/tracy": "^2.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause", - "GPL-2.0-only", - "GPL-3.0-only" - ], - "authors": [ - { - "name": "David Grudl", - "homepage": "https://davidgrudl.com" - }, - { - "name": "Nette Community", - "homepage": "https://nette.org/contributors" - } - ], - "description": "💾 Nette Database: layer with a familiar PDO-like API but much more powerful. Building queries, advanced joins, drivers for MySQL, PostgreSQL, SQLite, MS SQL Server and Oracle.", - "homepage": "https://nette.org", - "keywords": [ - "database", - "mssql", - "mysql", - "nette", - "notorm", - "oracle", - "pdo", - "postgresql", - "queries", - "sqlite" - ], - "time": "2020-02-04T12:48:51+00:00" - }, - { - "name": "nette/finder", - "version": "v2.5.2", - "source": { - "type": "git", - "url": "https://github.com/nette/finder.git", - "reference": "4ad2c298eb8c687dd0e74ae84206a4186eeaed50" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/nette/finder/zipball/4ad2c298eb8c687dd0e74ae84206a4186eeaed50", - "reference": "4ad2c298eb8c687dd0e74ae84206a4186eeaed50", - "shasum": "" - }, - "require": { - "nette/utils": "^2.4 || ^3.0", - "php": ">=7.1" - }, - "conflict": { - "nette/nette": "<2.2" - }, - "require-dev": { - "nette/tester": "^2.0", - "phpstan/phpstan": "^0.12", - "tracy/tracy": "^2.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.5-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause", - "GPL-2.0", - "GPL-3.0" - ], - "authors": [ - { - "name": "David Grudl", - "homepage": "https://davidgrudl.com" - }, - { - "name": "Nette Community", - "homepage": "https://nette.org/contributors" - } - ], - "description": "🔍 Nette Finder: find files and directories with an intuitive API.", - "homepage": "https://nette.org", - "keywords": [ - "filesystem", - "glob", - "iterator", - "nette" - ], - "time": "2020-01-03T20:35:40+00:00" - }, - { - "name": "nette/php-generator", - "version": "v3.4.1", - "source": { - "type": "git", - "url": "https://github.com/nette/php-generator.git", - "reference": "7051954c534cebafd650efe8b145ac75b223cb66" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/nette/php-generator/zipball/7051954c534cebafd650efe8b145ac75b223cb66", - "reference": "7051954c534cebafd650efe8b145ac75b223cb66", - "shasum": "" - }, - "require": { - "nette/utils": "^2.4.2 || ^3.0", - "php": ">=7.1" - }, - "require-dev": { - "nette/tester": "^2.0", - "nikic/php-parser": "^4.4", - "phpstan/phpstan": "^0.12", - "tracy/tracy": "^2.3" - }, - "suggest": { - "nikic/php-parser": "to use ClassType::withBodiesFrom() & GlobalFunction::withBodyFrom()" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause", - "GPL-2.0-only", - "GPL-3.0-only" - ], - "authors": [ - { - "name": "David Grudl", - "homepage": "https://davidgrudl.com" - }, - { - "name": "Nette Community", - "homepage": "https://nette.org/contributors" - } - ], - "description": "🐘 Nette PHP Generator: generates neat PHP code for you. Supports new PHP 7.4 features.", - "homepage": "https://nette.org", - "keywords": [ - "code", - "nette", - "php", - "scaffolding" - ], - "time": "2020-06-19T14:31:47+00:00" - }, - { - "name": "nette/utils", - "version": "v3.1.3", - "source": { - "type": "git", - "url": "https://github.com/nette/utils.git", - "reference": "c09937fbb24987b2a41c6022ebe84f4f1b8eec0f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/nette/utils/zipball/c09937fbb24987b2a41c6022ebe84f4f1b8eec0f", - "reference": "c09937fbb24987b2a41c6022ebe84f4f1b8eec0f", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "require-dev": { - "nette/tester": "~2.0", - "phpstan/phpstan": "^0.12", - "tracy/tracy": "^2.3" - }, - "suggest": { - "ext-gd": "to use Image", - "ext-iconv": "to use Strings::webalize(), toAscii(), chr() and reverse()", - "ext-intl": "to use Strings::webalize(), toAscii(), normalize() and compare()", - "ext-json": "to use Nette\\Utils\\Json", - "ext-mbstring": "to use Strings::lower() etc...", - "ext-tokenizer": "to use Nette\\Utils\\Reflection::getUseStatements()", - "ext-xml": "to use Strings::length() etc. when mbstring is not available" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.1-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause", - "GPL-2.0-only", - "GPL-3.0-only" - ], - "authors": [ - { - "name": "David Grudl", - "homepage": "https://davidgrudl.com" - }, - { - "name": "Nette Community", - "homepage": "https://nette.org/contributors" - } - ], - "description": "🛠 Nette Utils: lightweight utilities for string & array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.", - "homepage": "https://nette.org", - "keywords": [ - "array", - "core", - "datetime", - "images", - "json", - "nette", - "paginator", - "password", - "slugify", - "string", - "unicode", - "utf-8", - "utility", - "validation" - ], - "time": "2020-08-07T10:34:21+00:00" - } - ], - "packages-dev": [], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": [], - "prefer-stable": false, - "prefer-lowest": false, - "platform": [], - "platform-dev": [], - "plugin-api-version": "1.1.0" -} diff --git a/examples/db.sql b/examples/db.sql deleted file mode 100644 index 46ce246..0000000 --- a/examples/db.sql +++ /dev/null @@ -1,100 +0,0 @@ --- Adminer 4.2.1 MySQL dump - -SET NAMES utf8; -SET time_zone = '+00:00'; -SET foreign_key_checks = 0; -SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO'; - -CREATE DATABASE `nextras_orm_generator` /*!40100 DEFAULT CHARACTER SET latin1 */; -USE `nextras_orm_generator`; - -CREATE TABLE `book` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `category` int(10) unsigned NOT NULL, - `user` int(10) unsigned NOT NULL, - `image` int(10) unsigned DEFAULT NULL, - `name` varchar(100) NOT NULL, - `author` varchar(100) DEFAULT NULL, - `description` text NOT NULL, - `publisher` varchar(100) DEFAULT NULL, - `price` int(6) unsigned NOT NULL DEFAULT '0', - `year` int(4) unsigned DEFAULT NULL, - `wear` int(2) DEFAULT NULL, - `active` int(1) NOT NULL DEFAULT '0', - `state` enum('SELLING','SOLD','EXPIRED','UNKNOWN') NOT NULL DEFAULT 'UNKNOWN', - `updatedAt` datetime NOT NULL, - `createdAt` datetime NOT NULL, - PRIMARY KEY (`id`), - KEY `category` (`category`), - KEY `user` (`user`), - KEY `image` (`image`), - CONSTRAINT `book_ibfk_1` FOREIGN KEY (`category`) REFERENCES `category` (`id`), - CONSTRAINT `book_ibfk_2` FOREIGN KEY (`user`) REFERENCES `user` (`id`), - CONSTRAINT `book_ibfk_3` FOREIGN KEY (`image`) REFERENCES `image` (`id`) ON DELETE SET NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - -CREATE TABLE `book_x_image` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `image_id` int(10) unsigned NOT NULL, - `book_id` int(10) unsigned NOT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `image_id_book_id` (`image_id`,`book_id`), - KEY `book_id` (`book_id`), - CONSTRAINT `book_x_image_ibfk_1` FOREIGN KEY (`image_id`) REFERENCES `image` (`id`) ON DELETE CASCADE, - CONSTRAINT `book_x_image_ibfk_2` FOREIGN KEY (`book_id`) REFERENCES `book` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - -CREATE TABLE `category` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(50) COLLATE utf8_czech_ci NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci; - - -CREATE TABLE `image` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `filename` varchar(255) NOT NULL, - `createdAt` datetime NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - -CREATE TABLE `message` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `user` int(10) unsigned NOT NULL, - `book` int(10) unsigned NOT NULL, - `message` text COLLATE utf8_czech_ci NOT NULL, - `createdAt` datetime NOT NULL, - PRIMARY KEY (`id`), - KEY `user` (`user`), - KEY `book` (`book`), - CONSTRAINT `message_ibfk_1` FOREIGN KEY (`user`) REFERENCES `user` (`id`), - CONSTRAINT `message_ibfk_2` FOREIGN KEY (`book`) REFERENCES `book` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci; - - -CREATE TABLE `test` ( - `id` int(11) NOT NULL DEFAULT '5', - `def` varchar(255) COLLATE utf8_czech_ci NOT NULL DEFAULT 'ahoj1', - `time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `date` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci; - - -CREATE TABLE `user` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `fbid` varchar(100) DEFAULT NULL, - `username` varchar(100) NOT NULL, - `password` varchar(100) NOT NULL, - `role` enum('USER','ADMIN') NOT NULL DEFAULT 'USER', - `loggedAt` datetime NOT NULL, - `createdAt` datetime NOT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `username` (`username`), - UNIQUE KEY `fbid` (`fbid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - --- 2015-06-30 10:14:47 diff --git a/examples/db.sqlite b/examples/db.sqlite new file mode 100644 index 0000000..ffd6764 Binary files /dev/null and b/examples/db.sqlite differ diff --git a/examples/seperate.php b/examples/seperate.php index e717ca7..83cfdb4 100644 --- a/examples/seperate.php +++ b/examples/seperate.php @@ -1,14 +1,19 @@ - __DIR__ . '/model/separate']), - new DatabaseAnalyser('mysql:host=127.0.0.1;dbname=nextras_orm_generator', 'root') + new SeparateConfig(['output' => __DIR__ . '/model/separate']), + new DatabaseAnalyser('sqlite:db.sqlite') ); $factory->create()->generate(); diff --git a/examples/together.php b/examples/together.php index 3e746de..aed82b9 100644 --- a/examples/together.php +++ b/examples/together.php @@ -1,15 +1,19 @@ - __DIR__ . '/model/together']), - new DatabaseAnalyser('mysql:host=127.0.0.1;dbname=nextras_orm_generator', 'root') + new DatabaseAnalyser('sqlite:db.sqlite') ); -$factory->create()->generate(); \ No newline at end of file +$factory->create()->generate();