Issues with doctrine build in Symfony - php

I am getting stuck with this Symfony command after following the Jobeet tutorial on their site. After running the build model command, here's what I get:
$ php symfony doctrine:build --model
doctrine generating model classes
file+ /private/var/folders/yX/yXtbVXwPHcCUpfC-n06OAU+++TI/-Tmp-/doctrine_schema_56533.yml
No yml schema found in /private/var/folders/yX/yXtbVXwPHcCUpfC-n06OAU+++TI/-Tmp-/doctrine_schema_56533.yml
Any ideas?

What's then full path to your schema.yml? Looks like it might be in the wrong place.
I encountered a couple of issues in the jobeet tutorial and found it helpful to compare my file contents/paths to the tag for the relevant day at http://svn.jobeet.org/doctrine/tags/

Did you make sure that all your schema code is YAML compliant?
Maybe you can share the content of your current schema.yml with us.

Related

Sylius ProductBundle/ResourceBundle : how to enable HTML routing for products?

I am trying to install some bundles provided by Sylius, but I don't want to install it fully. I began with ProductBundle. I'm using the v0.15.
After some struggle, I managed to create the schema in my database and enabled the router for the API endpoint of products. The code shown in the ProductBundle documentation fails, but I managed to have my routes with this code:
app_product:
resource: app_product
type: sylius.api
I guess it's thanks to the #SyliusResourceBundle/Routing/ApiLoader.php class.
However, I would like to test the type sylius.resource described in the ResourceBundle documentation.
I can't find the definition of the loader - if there is one. And it collapses as soon as I try php app/console debug:router :
[Symfony\Component\Config\Exception\FileLoaderLoadException]
Cannot load resource "alias: app.product
".
with the config:
app_product:
resource: |
alias: app.product
type: sylius.resource
Can anyone point me to a correct configuration ?
Or could someone point me to a Loader or a similar tool that is defined somewhere in the code ?
Thanks for your time
I finally understood how is that suppose to work. Sorry for answering to my own question, but if anyone actually come accross the same problem, it might help.
The documentation is actually up to date with the dev version of the project. If you still want to stick with some previous versions, you have to define your own routes as you would do in a standard Symfony application.
You can help yourself with php app/console debug:container to see what actually was created for your resource/product.
For french speaking developers, this talk helped me a lot :
http://fr.slideshare.net/ArnaudLanglade/dvelopper-avec-le-sylius-resourcebundle

Ambiguous Tutorial - Getting Started with Doctrine

I'm trying to work through this tutorial.
http://doctrine-orm.readthedocs.org/en/latest/tutorials/getting-started.html
But get stuck at the point where I have to create the schema.
php vendor/bin/doctrine orm:schema-tool:create
Always getting:
No Metadata Classes to process.
I tried the solutions presented by the following post in vain:
Doctrine2 - No Metadata Classes to process
and
Doctrine2: Getting Started Tutorial "No Metadata Classes to process"
Any suggestions ? I'm stuck here for about three hours :-/
Metadata for entities are configured using a XML, YAML or Docblock
Annotations. This Getting Started Guide will show the mappings for all
Mapping Drivers. References in the text will be made to the XML
mapping.
Maybe I misunderstood. But when I read
References in the text will be made to the XML mapping
I used the XML file to configure the metadata. But I should have used the Docblock Annotations, that's all I had to do.

Cleaning a Symfony project and installing a new bundle

Im very new to Symfony, yet Im already familiar to the MCV model, after a while reading the documentation I have now the standard edition of Symfony 2 running on my server.
Fresh start
As you know Symfony comes with a hello world app and some welcome scripts, how can I clean all of that?, even better, is there a way to install a Symfony project without the examples bundles?
Data base structure restore
In the past, every time I developed an app with database, I created the structure of the tables using phpmyadmin and then an initial php script that restore that database if I need to install my app on other server. Working with Symfony is quite different, I read that it use doctrine and the Symfony core restore the database format using some internal files. I have a bundle that I need to install, I know that this bundle/app use MySQL, I set the config file with all my MySQL information but I dont know how I can run a sript that will restore a clean database needed for that particular app. I know it has something to do with php app/console schema:update but not so sure.
Thanks for any orientation.
how can I clean all of that?, even better, is there a way to install a Symfony project without the examples bundles?
There is no way to do that in Symfony2 and it looks like it never become a part of the Symfony2 project:
"I think that we need clear instructions on how to remove the Acme demo code by hand. I'm -1 on added a CLI command to do that automatically."
-- fabpot on github
The things you should do:
Remove the src/Acme directory
Remove $bundles[] = new Acme\DemoBundle\AcmeDemoBundle(); (line 25) in app/AppKernel.php
Remove the related routes from app/config/routing_dev.yml (_welcome, _demo_secured and _demo)
You can remove everything in the security: key in app/config/security.yml and place enabled: false in it. However, this isn't needed and it works like a nice boilerplate for your own security
Your other question: Symfony2 don't have a 'view' layer. You can choose to use whatever you want. But Symfony2 included 2 ORMs in their framework by default, Doctrine and Propel. You can read more on how to work with these libraries in the documentation: Doctrine and Propel.

Doctrine/ZF z2d2 tutorial issue

I'm sure that I'm missing something, but I've spent all day and I still can't get this skeleton doctrine integration project by Jason Gilmour to work:
github link
It's quite a simple project, but (after configuring in application.ini) I run into difficulty trying to generate the schema:
./scripts/doctrine orm:schema-tool:create
GIVES
PHP Fatal error: Cannot redeclare class Entities\Account in /var/www/z2d2/application/models/Entities/Account.php on line 12
I think it has something to do with namespaces.
I am using php 5.3.6.
Thanks,
Demian.
I downloaded the source from github here and it seems that the author has made a mistake in the file /application/model/entities/Rank.php. This file is just a duplicate of Account.php - hence the error...
Just delete Rank.php and create your own (or even don't)
Apart from this issue, it looks like a great skeleton to implement zend framework with doctrine.
Thanks for the comments those who responded.
D.

Doctrine 2 mapping - cant auto generate yml files

I'm trying to get doctrine 2 work for me (I used to work with d1)
but I can't get doctrine generate the models (like on doctrine1)
I have downloaded the lastest version of doctrine 2.1
so my directory tree looks like that :
C:\doctrine\bin - got it from the tar file
C:\doctrine\Doctrine - got it from the tar file
C:\doctrine\models - created by me for mapping info
I also edited the bin doctrine.php file and added cli-config.php file and its looking like that:
C:\doctrine\bin\doctrine.php --> http://pastebin.com/Ki62hbTX
C:\doctrine\bin\cli-config.php --> http://pastebin.com/cPv4fXX1
Now when I'm going to cmd this is the result:
c:\doctrine\bin>php doctrine orm:schema-tool:create
No Metadata Classes to process.
I checked the paths of files, write permissions, db login info and every thing but I can't find out how to read db and generate the class
any idea will be great, thanks
There might be several problems here, but let me start by saying that I just moved to doctrine2 from 1.2 and it is way easier to use php annotations in doctrine2. Then you're creating the class yourself....everything just seems to make sense a little more.
But, if you want to use YAML, be aware that with YAML and Doctrine2, the YAML hierarchy is completely different. So you can't just load your doctrine1 yaml into doctrine2.
Here's the guide to YAML in doctrine 2: http://www.doctrine-project.org/docs/orm/2.0/en/reference/yaml-mapping.html
The one thing that I found is that Doctrine2 wanted a specific folder for my namespace. So my entities are in entities/NAMESPACE/ rather than just entities/. Also note that you need a separate file for each class and the naming conventions are very strict.

Categories