I installed propel and want to test the example from http://propelorm.org/documentation/02-buildtime.html . But when I want to generate the SQL-Code there is nothing happens. I tried it as described with: propel.bat sql:build –verbose
- But when I use CMD located at my test-folder (where the propel.ini, .json, .xml, .yaml and schema.xml located) nothing happens even no error.
If I delete the propel.php file in my test-folder than I got this error:
[Symfony\Component\Config\Definition\Exception\InvalidConfigurationException]
The child node "database" at path "propel" must be configured. - If I’m located at any other place I got this error:
[Propel\Common\Config\Exception\InvalidArgumentException]
Propel expects only one configuration file
I have set the PATH to PHP and to \vendor\bin from propel.
I suppose that the problem is something between the file \vendor\propel\propel.php and the file propel.php in my testfolder.
I used the following files:
- List item
Propel.php (I’m not sure with the propel.php because on the page mentioned at the beginning it starts with “” is missing). I tried both.
<?php
return [
'propel' => [
'database' => [
'connections' => [
'bookstore' => [
'adapter' => 'mysql',
'classname' => 'Propel\Runtime\Connection\ConnectionWrapper',
'dsn' => 'mysql:host=localhost;dbname=my_db_name',
'user' => 'propel',
'password' => 'propel',
'attributes' => []
]
]
],
'runtime' => [
'defaultConnection' => 'bookstore',
'connections' => ['bookstore']
],
'generator' => [
'defaultConnection' => 'bookstore',
'connections' => ['bookstore']
]
]
];
Propel.xml
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<config>
<propel>
<database>
<connections>
<connection id="bookstore">
<adapter>mysql</adapter>
<classname>Propel\Runtime\Connection\ConnectionWrapper</classname>
<dsn>mysql:host=localhost;dbname=my_db_name</dsn>
<user>propel</user>
<password>propel</password>
<attributes></attributes>
</connection>
</connections>
</database>
<runtime>
<defaultConnection>bookstore</defaultConnection>
<connection>bookstore</connection>
</runtime>
<generator>
<defaultConnection>bookstore</defaultConnection>
<connection>bookstore</connection>
</generator>
</propel>
</config>
Propel.yaml
propel:
database:
connections:
bookstore:
adapter: mysql
classname: Propel\Runtime\Connection\ConnectionWrapper
dsn: "mysql:host=localhost;dbname=my_db_name"
user: propel
password: propel
attributes:
runtime:
defaultConnection: bookstore
connections:
- bookstore
generator:
defaultConnection: bookstore
connections:
- bookstore
Propel.json
{
"propel": {
"database": {
"connections": {
"bookstore": {
"adapter": "mysql",
"classname": "Propel\Runtime\Connection\ConnectionWrapper",
"dsn": "mysql:host=localhost;dbname=my_db_name",
"user": "propel",
"password": "propel",
"attributes": []
}
}
},
"runtime": {
"defaultConnection": "bookstore",
"connections": ["bookstore"]
},
"generator": {
"defaultConnection": "bookstore",
"connections": ["bookstore"]
}
}
}
Propel.ini
[propel]
;
; Database section
;
database.connections.bookstore.adapter = mysql
database.connections.bookstore.classname = Propel\Runtime\Connection\ConnectionWrapper
database.connections.bookstore.dsn = mysql:host=localhost;dbname=my_db_name
database.connections.bookstore.user = propel
database.connections.bookstore.password = propel
database.connections.bookstore.attributes =
;
; Runtime section
;
runtime.defaultConnection = bookstore
runtime.connections[0] = bookstore
;
; Generator section
;
generator.defaultConnection = bookstore
generator.connections[0] = bookstore
schema.xml
<?xml version="1.0" encoding="UTF-8"?>
<database name="bookstore" defaultIdMethod="native">
<table name="book" phpName="Book">
<column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true"/>
<column name="title" type="varchar" size="255" required="true" />
<column name="isbn" type="varchar" size="24" required="true" phpName="ISBN"/>
<column name="publisher_id" type="integer" required="true"/>
<column name="author_id" type="integer" required="true"/>
<foreign-key foreignTable="publisher" phpName="Publisher" refPhpName="Book">
<reference local="publisher_id" foreign="id"/>
</foreign-key>
<foreign-key foreignTable="author">
<reference local="author_id" foreign="id"/>
</foreign-key>
</table>
<table name="author" phpName="Author">
<column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true"/>
<column name="first_name" type="varchar" size="128" required="true"/>
<column name="last_name" type="varchar" size="128" required="true"/>
</table>
<table name="publisher" phpName="Publisher">
<column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true" />
<column name="name" type="varchar" size="128" required="true" />
</table>
</database>
These files were autogenerated from propel in vendor/bin
Propel.bat
@ECHO OFF
SET BIN_TARGET=%~dp0/../propel/propel/bin/propel
php "%BIN_TARGET%" %*
propel
#!/usr/bin/env sh
SRC_DIR="`pwd`"
cd "`dirname "$0"`"
cd "../propel/propel/bin"
BIN_TARGET="`pwd`/propel"
cd "$SRC_DIR"
"$BIN_TARGET" "$@"
and these in vendor/bin/propel/propel/bin
propel
#!/usr/bin/env php
<?php
include('propel.php');
propel.bat
@echo off
if "%PHPBIN%" == "" set PHPBIN=php
if not exist "%PHPBIN%" if "%PHP_PEAR_PHP_BIN%" neq "" goto USE_PEAR_PATH
GOTO RUN
:USE_PEAR_PATH
set PHPBIN=%PHP_PEAR_PHP_BIN%
:RUN
"%PHPBIN%" "bin\propel" %*
Propel.php
<?php
if (!class_exists('\Symfony\Component\Console\Application')) {
if (file_exists($file = __DIR__.'/../../../autoload.php') || file_exists($file = __DIR__.'/../autoload.php')) {
require_once $file;
} elseif (file_exists($file = __DIR__.'/../autoload.php.dist')) {
require_once $file;
}
}
use Symfony\Component\Console\Application;
use Symfony\Component\Finder\Finder;
use Propel\Runtime\Propel;
$finder = new Finder();
$finder->files()->name('*.php')->in(__DIR__.'/../src/Propel/Generator/Command')->depth(0);
$app = new Application('Propel', Propel::VERSION);
foreach ($finder as $file) {
$ns = '\\Propel\\Generator\\Command';
$r = new \ReflectionClass($ns.'\\'.$file->getBasename('.php'));
if ($r->isSubclassOf('Symfony\\Component\\Console\\Command\\Command') && !$r->isAbstract()) {
$app->add($r->newInstance());
}
}
$app->run();