2015-09-11 1 views
0

J'ai installé propel et je veux tester l'exemple de http://propelorm.org/documentation/02-buildtime.html. Mais quand je veux générer le code SQL, il ne se passe rien. Je l'ai essayé comme décrit avec: propel.bat sql: construire verbosePropel ne démarre pas

  • Mais quand j'utilise CMD installé dans mon dossier test (où le propel.ini, .json, .xml, .yaml et schéma .xml situé) rien ne se passe même pas d'erreur. Si je supprime le fichier propel.php dans mon test-dossier que je suis arrivé cette erreur:
    [Symfony \ Component \ Config \ Définition \ Exception \ InvalidConfigurationException]
    Le nœud enfant "base de données" au chemin « propulsent "doit être configuré.
  • Si je suis situé à tout autre endroit où je suis arrivé cette erreur:
    [Propel \ Common Files \ Config \ Exception \ InvalidArgumentException]
    Propel attend qu'un seul fichier de configuration

J'ai mis la PATH à PHP et à \ vendor \ bin à partir de propel. Je suppose que le problème est quelque chose entre le fichier \ vendor \ propel \ propel.php et le fichier propel.php dans mon dossier de test.

J'utilise les fichiers suivants:

  • Liste item

Propel.php (je ne suis pas sûr de la propel.php car sur la page mentionné au début, il commence avec "" est manquant). J'ai essayé les deux.

<?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> 

Ces fichiers ont été générées automatiquement à Propel dans vendor/bin
Propel.bat

@ECHO OFF 
SET BIN_TARGET=%~dp0/../propel/propel/bin/propel 
php "%BIN_TARGET%" %* 

propulsent

#!/usr/bin/env sh 
SRC_DIR="`pwd`" 
cd "`dirname "$0"`" 
cd "../propel/propel/bin" 
BIN_TARGET="`pwd`/propel" 
cd "$SRC_DIR" 
"$BIN_TARGET" "[email protected]" 

et ceux-ci dans le fournisseur/bin/propulser/Propel/bin
propulsent

#!/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(); 

Répondre

0

J'ai trouvé la solution du problème. J'avais trop de fichiers dans mon dossier de travail: j'avais propel.xml, .yaml, .php, .json, .ini et le scheme.xml. Quand je décide juste de prendre le propel.xml et le scheme.xml tout semble fonctionner.