fmunoz92 / silex-angular

REST API PHP Silex + Angular + Bootstrap
https://github.com/fmunoz92/silex-angular
MIT License
2 stars 0 forks source link

Unclear Install Instructions #1

Open ghost opened 9 years ago

ghost commented 9 years ago

Hello

"Create the database for tests then put the env var SILEX_MODE=test update test data base params in config/env/test.json"

Can you elaborate on this? What Database should I create and where is the *.sql file? Where do I need to edt the SILEX_MODE=test in?

Sincerely

fmunoz92 commented 9 years ago

Hello! thanks for your comment.

You have to export the environment variable SILEX_MODE, for example in Unix Systems just run in the bash console:

$ export SILEX_MODE="test" 

The system takes this variable to select some file of config/env folder https://github.com/fmunoz92/silex-angular/tree/master/config/env So, if you set the var as "test" the configuration loaded will be https://github.com/fmunoz92/silex-angular/blob/master/config/env/test.json

Is not necessary have a sql file, you just have to run the following command to create/update the database(selected in config/env/test.json):

php vendor/bin/doctrine orm:schema-tool:update --force

Please let me know if you have any issue, I will help you.

And feel free to fork and make a pull request if there is something you'd love(For example this explanation :smiley:).

Best Regards, Facundo M.

ghost commented 9 years ago

Thank you for your Feedback. I'm not sure if I have understand Doctrine already, so the problem I have might be there.

I'm on Win7, so pardon my Bash:

    X:\Code\Silex\silex-angular (master)
    λ ls
    AUTHORS  LICENSE  README.md  TODO  app  bower.json  cli-config.php  composer.json  composer.lock  config  index.php  phpunit.xml.dist  public  temp  tests  vendor

    X:\Code\Silex\silex-angular (master)
    λ php vendor/bin/doctrine orm:schema-tool:update --force
    SRC_DIR="`pwd`"
    cd "`dirname "$0"`"
    cd "../doctrine/orm/bin"
    BIN_TARGET="`pwd`/doctrine"
    cd "$SRC_DIR"
    "$BIN_TARGET" "$@"

Is this how it should look like? Yesterday I installed bower and the day before composer. I think I have doctrine now installed but totaly ignore what it actually does. All those Tools now a days making it really complex to get a boilerplate of a project up and running, but I think they have their logic.

I also tried after reading some stackoverflow about Win7 and doctrine:

    λ php vendor/bin/doctrine orm:schema-tool:create --force

my DB credentials in test.json are fine but in my php my admin are no tables added, so I assume it did not worked. Is there really no simple *.sql technique? Webdev really but on a lot of batchtools dependecys while fighting the problem of library dependencies :)

Thank you for your support.

Mortimer

fmunoz92 commented 9 years ago

No problem, It seems that in Windows you have to run a different command. Please take a look: http://stackoverflow.com/questions/15627784/doctrine-cli-on-windows Please let me know if some solution works for you and I will update the README.md

fmunoz92 commented 9 years ago

Please try with this command:

php vendor/doctrine/orm/bin/doctrine orm:schema-tool:update --force
ghost commented 9 years ago

I've read some other threads about doctrine. Very confusing.

I tried you statement then:

X:\Code\Silex\silex-angular (master)
λ php vendor/doctrine/orm/bin/doctrine orm:schema-tool:update --force
PHP Warning:  PDO::__construct(): php_network_getaddresses: getaddrinfo failed: Der angegebene Host ist unbekannt.  in X:\Code\Silex\silex-angular\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOConnection.php on line 36

Warning: PDO::__construct(): php_network_getaddresses: getaddrinfo failed: Der angegebene Host ist unbekannt.  in X:\Code\Silex\silex-angular\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOConnection.php on line 36

  [PDOException]
  SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Der angegebene Host ist unbekannt.

orm:schema-tool:update [--complete] [--dump-sql] [--force]

Turned out, my DB Credentials were set right, but to an external Database. And PDOConnection doesnt like that:

The .mysql based hosts are internal hosts within the one.com network that resolves to the server that hosts your database. These hosts are not meant for connections outside of one.com hosting, and probably doesn't accept connections from the world if they're even available on a public IP.

I now use a local enviroment with a local mysql service and repeated your command:

php vendor/doctrine/orm/bin/doctrine orm:schema-tool:update --force

and received

Updating database schema...
Database schema updated successfully! "2" queries were executed

And I can see the DB Tables in my PHP MyAdmin.

Now, I thought I could point to the local path and see some magic working, but not yet as it seems: http://127.0.0.1/silex-angular/

Fatal error: Class 'Twig_Function_Method' not found in X:\Code\Silex\silex-angular\vendor\silex\silex\src\Silex\Provider\TwigCoreExtension.php on line 27

Any ideas what is now broken?

Mortimer

fmunoz92 commented 9 years ago

I don't have any ideas for this Twig error, I will try to run it in a PC with Windows to fix the error.

ghost commented 9 years ago

I still got the same error message but want to add this. Can it be that Twig_Function_Method depreceated is? Why is it still in the silex code?

Mortimer