I'm pretty new at Symfony 2 and I was wondering something :
Let's assume I have 2 bundles in my projects. I want to use entities generated from my database in both bundles.
Where am I suppose to generate the entities ? (To me the best way would be outside the bundles but I can't find out how to do that)
Thanks for your help.
I think there is two solutions, you have to think of the design of your application.
Are you sure you need two bundles ? If the link is so strong between the two, why didn't you choose to make only one bundle ? In this case, you'll just have to generate the entities into this bundle.
Other case : you effectively need two bundles, but in this specific application you need to make a link between the two. In this case, I think you should generate the entities in the bundle where it belongs, and if you need so you can use them in another bundle (thank to use MyApp\MyBundle\Entities\...;). You have to think in terms of generic code when using Symfony, in order to be able to reuse your bundles in other projects. ;)
Related
I'm looking for advice on structuring FlatBuffer schemas for a framework which allows users to extend the data types defined by the framework, but also allows the framework developers to add new fields when new versions of the framework are published.
My original thinking was that when you create a project using this framework, it would generate several FlatBuffer schema files which you could then edit for your specific project. You could then compile the schemas and start developing code using the framework APIs.
However, this becomes a problem when the framework developers decide to add fields to the base types. As you probably know, FlatBuffers requires that any additional fields be appended to the end (or at least have a higher ID than other fields). So there is a conflict between the additions made by the framework developer and the framework user.
One possible solution would be to have a set of 'non-user-extensible' types that are owned by the framework creator, and which should not be modified by users of the framework; and these types would then be embedded within the data types defined by the framework user. However, given the restrictions on fields changing size, I am not sure if this would even work.
I'm also willing to hear alternatives to using flatbuffers if it turns out that there is no good solution otherwise.
To have open ended extension like that, you should really have the framework authors and users work in two separate tables.. where one can own the other. There is no good way to extend a single table if all contributors aren't sharing the schema in source control.
If these extensions must be in a single object for whatever reason, then Protocol Buffers is more flexible than FlatBuffers, since it doesn't require adjacent field ids. You can simply say that all field ids >=1000 are for framework users, for example.
In retrospect (answering my own question two years later), it seems that FlatBuffers was not the right choice for my use case. These days I'm using a combination of msgpack (in cases where I care about byte-size) and JSON (in cases where I don't) and I'm pretty happy with each.
I want to get all userstores regardless their projects. can this be done in one query?
I have a recursive logic and looping over projects, for each project doing this logic can't work for me as some US have parents in different projects
any idea?
The short answer is by including workspace=/workspace/12345&project=null as query string parameters in your WSAPI request url. How are you accessing the WSAPI? App SDK 1? 2? There are different ways to do this depending on what toolkit you are using.
Is there a good, clean and simple way to delete entities non-destructively in Symfony 2? I'd like to give my administrators a chance to undelete items, while sacrificing as little of the automation provided by the framework as possible.
If there is no built-in solution or third party bundle to help me, what would be the best way to do this? Adding a deleted property to entities would require lots of added logic to keep them from cluttering the controllers created by doctrine:generate:crud, so maybe they should be stored in a separate table in serialized form?
What you want is Soft Delete. There is a Doctrine extension for that and a bundle to integrate it with Symfony.
I think its quite usual task, but still solutions I saw look not so nice.
For example in Qt used approach based on MVC pattern -- you must assign all connections manually.
Or I remember one PHP engine where pages were creating from DB schema.
Which are other approaches? Which one you are prefer? What are the best practices?
Usually, there is not a one to one mapping from the database to the GUIThere are many subtle combinations that change between how you store the data and how that stored data is visualized and edited by the user.
however, you can automate a datamodel layer in your code with tools like Hibernate. You will still need to use the model as required to present your user interface.
I have a maven multimodule project. What the best practices for creating groupId? Can I use one common groupId for all modules or unique per each?
There is no general rule. Use the groupId to separate (or not) things that have different concerns, but coarse grained. XWiki is a good illustration of this approach. Hibernate is another example, they use the same groupId for all their modules.
But nothing forces you to use a unique groupId per module, this seems clearly too fine grained to me (this sounds like creating a package for each class).
In a corporate environment, using something like a.b.appname and then a.b.appname.moduleN if the application is big and has many modules is a common pattern.