How can I properly switch the newly installed Symfony 1.4 framework from Doctrine (that it is configured for by default) to Propel?
If you create new (fresh) project...
symfony generate:project xxx --orm=Propel
The easiest thing :)
If you want to change existing project - you have to dig in configuration file and enable propel plugin.
Your configuration file should look similar to:
// config/ProjectConfiguration.class.php
public function setup()
{
$this->enablePlugins('sfPropelPlugin');
...
}
(based on Symfony page, you should dig it next time - especially Practical Symfony)
Use Propel if you enjoy object-oriented syntax.
If you like chained object method calls that look like SQL statements, use Doctrine. If you like real objects that hide SQL, use Propel.
If you like creating criteria objects that then render themselves as WHERE clauses, use Propel. If you like creating WHERE clauses similar to SQL, use Doctrine.
You can use both at the same time, too. Not recommended, but if you use plugins like apostrophe that only use Doctrine, you might not have a choice.
Replying to the contributors here who wholly recommend Doctrine: the decision is not clear cut, in my view. Propel now also supports chainable query methods, so if you like that approach then both are still in play. Also, the Propel team maintain that the generated nature of model objects makes it faster to run for most use-cases than Doctrine.
Related
I need information about node's creation & last modification dates...
Is there a way to automatically handle created and updated properties for a node?
Hibernate offers #Version for updated field. Is there something similar with Node4J.
I found http://neo4j.rubyforge.org/classes/Neo4j/Rails/Timestamps.html but it seems to be only available for Ruby.
You can use annotations form the spring-data-commons library. Use #CreatedDate and #LastModifiedDate on properties of type Long. Make sure you're using the simple mapping mode. For now, advanced mapping mode does not support this, see DATAGRAPH-335.
In our application, numerous emails are being sent from the system. These emails were of the same format for all users with different contextual variables populating the dynamic data.
We are now planning a feature to allow administrators to edit and customize these templates. As such the plan is to use the groovy shell to evaluate the templates at run time e.g.
Binding binding = new Binding();
binding.setVariable("model", [var1: "First Name", var2: "Last Name"])
GroovyShell shell = new GroovyShell(binding);
Object email = shell.evaluate('return "<html><title>Test Shell</title><body>${model.var1} ${model.var2}</body></html>";');
This seems to work adequately for us. The questions I have are:
Is the GroovyShell the preferred engine to use or is Rhino or other better?
Are there any performance concerns or memory issues to be aware of? Any low hanging fruit we can optimize i.e. can the shell or binding be reused
What's the biggest bottleneck in the above code? The construction? The evaluation?
thanks
I would recommend using something like GroovyPagesTemplateEngine because it goes beyond just Groovy eval and you and you can use all the grails taglib goodness as well. I'm using both GroovyPagesTemplateEngine and SimpleTemplateEngine for your exact scenario.
SimpleTemplateEngine is slightly faster so if I don't need much more than simple binding I use it. When I need to deal with logic and control structures, I use GroovyPagesTemplateEngine.
For grails, use the page rendering api instead. http://grails.org/doc/2.0.x/guide/introduction.html#whatsNew
I am creating a web project and want it to be optimized. Instead of accessing lookup values in the database (to minimize access), I think it should be stored somewhere in symfony. What is the best way to this? In YML with PHP Array?
You can put values that don't change often in lib/app.yml
You can access those values by using sfConfig::get('value').
app.yml is cool because you can store enviroment specific values in it.
Another option I use for values that should never change and that are not environment-specific is to define constants in a relevant model or helper class.
The advantages are:
1) if you name those constants well using them helps make the code more self-documenting
2) if you use an IDE with autocompletion features it will look up and verify their names as you're coding.
3) they are the fastest possible method of lookup.
Is there a lint utility for ASP.NET MVC? Given that I frequently specify views and links via strings, when I move things around or change entity names I often break things, which I then only find out about when something fails at runtime.
ReSharper's v6 (whose nightlies are now available, if you don't mind living on the edge) will catch this kind of error for you.
You can use Refactor -> Rename and enable Search in Strings to replace every string in the solution
Other option -- use the strongly typed helpers (which might still be in the futures assemblies). EG, Html.Action<ProductsController>(x => x.ShowProduct(id)) ; really the only way to fly.
I don't know that there's something like that, but I'll tell you what I do: All my view names are in a struct that contains string constants. It's a pain to keep it sync'ed as the project changes, but it's worth it because you're far more likely to catch errors if you're using
ViewNames.Customer
rather than
"customer"
I am using mysql-workbench-doctrine-plugin and it is definitely something which is very useful! However I need something more robust which can handle more exceptional cases! The current plug in has some issues like:
Generates duplicate relationship name. For example if one table has two separate column having relationship with another particular table, then it will generate same name for the relationship (model class name of that particular table)
foreingAlias name: if the table name is user_phonenumber then foreign alias would be userPhonenumber, but it is better to have it like UserPhonenumber as it will look better to call like getUserPhonenumber than getuserPhonenumber. However this can be changed by tweaking the DoctrineExport.grt.lua file of the plugin..
if sfGuard plugin is used then all the sfDoctrineGuard related model classes are generated like SfDoctrineGuard* which breaks the plugin as it uses smaller 'sf' not 'Sf' as the name. (this is not a big issue as it is an exception for this plugin) .
What is the situation now is that I need to tweak a lot whenever I make changes to my database design in the workbench and generate yml for doctrine from it. I need something more powerful so that I need less tweaking to work seamlessly back and forth as project grows and evolves! Any suggestion ? Or what do you do when your database is big and changes a lot?
I've been using ORM Designer with great success. Its quirky with Doctrine 2, but it generates the entities for you with proper ORM relationships
http://www.orm-designer.com/