EzDevInfo.com

symfony1

Fork of symfony 1.4 with DIC, form enhancements, latest Swiftmailer, better performance, composer compatible and PHP 5.5+ support

Doctrine_Core::getTable()->findAll() how to specify order?

When using a Doctrine_Table object, is it possible to specify the order of the returned collection when using findAll() or findByWhatever()?

In the doc's I see some stuff about getOrderByStatement() and processOrderBy() but it isn't clear on how to use them...


Source: (StackOverflow)

How to set different template layout for different modules in Symfony

How to set different template layouts for different modules in Symfony?

I have a banking application that consists of a login screen, and a member section. So when a user goes to my site he will be presented with a login screen. After login in he will be redirected to the member section that he can do his whatever banking needs.

So, how to set different layouts for the login screen and the pages inside the member section? Symfony seems to use frontend/templates/layout.php as the template for ALL pages. Is it possible to define different layouts?


Source: (StackOverflow)

Advertisements

What is the Symfony2 equivalent of components in Symfony1?

In my Symfony2 application, I want to have a widget displayed on various pages. This can't just be defined by its template, it need to call the DB and go through the controller.

In Symfony1, I would create a component and include it. How can I do the same in Symfony2?


Source: (StackOverflow)

How to specify Composer install path?

I have this definition:

{
    "repositories": [
        {
            "type": "package",
            "package": {
                "name": "symfony/sfGuardPlugin",
                "version": "4.0.2",
                "dist": {
                    "url": "http://plugins.symfony-project.org/get/sfGuardPlugin/sfGuardPlugin-4.0.2.tgz",
                    "type": "tar"
                }
            }
        }
    ],
    "require": {
        "symfony/sfGuardPlugin": "4.0.*"
    }
}

I am using Symfony 1, and I'd like to install them on plugins/sfGuardPlugin/. How do I specify this?


Source: (StackOverflow)

Using Raw SQL with Doctrine

I have some extremely complex queries that I need to use to generate a report in my application. I'm using symfony as my framework and doctrine as my ORM.

My question is this:

What is the best way to pass in highly-complex sql queries directly to Doctrine without converting them to the Doctrine Query Language? I've been reading about the Raw_SQL extension but it appears that you still need to pass the query in sections (like from()). Is there anything for just dumping in a bunch of raw sql commands?


Source: (StackOverflow)

PHP ORMs: Doctrine vs. Propel

I'm starting a new project with symfony which is readily integrated with Doctrine and Propel, but I of course need to make a choice.... I was wondering if more experienced people out there have general pros and/or cons for going with either of these two?

Thanks a lot.

EDIT: Thanks for the all the responses, useful stuff. There's no truly correct answer to this question so I'll just mark as approved the one that got the most popular up-votes.


Source: (StackOverflow)

Should someone with no PHP experience use a framework like CakePHP or Symfony?

I have a simple site to develop and would like to learn PHP as I go. I want the site to be secure, scalable, and easy to maintain. Should I learn a framework and PHP simultaneously? If I build off of a framework there will be lots of unfamiliar code in play. Would you say this increases security risks?


Source: (StackOverflow)

Java 1.6 Broken when called by background Symfony task

I have a Symfony task that generates some files calls exec to a jar and then parses the output. The jar runs fine from the command line, the task runs fine from the command line.

The problem:

I call the task in an action based on a form submission. I have the action start a new php process in the background to run the task regardless of what the page the spawned it does now.

When it gets to the java call, say exec(java -version); it outputs this:

Error occurred during initialization of VM
Unable to load native library: libjava.jnilib

I feel like it has to do with the way I call php when I start the task but I'm lost as to why it wouldn't have the same libraries as when I use the command line.

How can I make java run from the 'background' Symfony task?

Notes:

It used to work with no hitch until I upraded mamp from 1.9.6 to 2.0.3.

I've looked at: Broken Java Mac 10.6 but since I can run it fine from the command line it seems to be a different issue.

I've also looked at Execute symfony task command from the shell_exec() permission denied but I don't think permissions are the issue here.

Update:

I've narrowed down the problem to MAMP and getting to php from the browser.

<?php
echo exec("java -version")
...

Will work when called from the command line but not when the php file is opened through the browser. So the way MAMP is configured is causing the issue.

Here's the environment info:

  • Variable Value
  • SHELL /bin/bash
  • TMPDIR /var/folders/YH/YH+uW3hDHZyxQ5AiUtr0T++++TI/-Tmp-/
  • Apple_PubSub_Socket_Render /tmp/launch-3rr9ZI/Render
  • USER myuser
  • COMMAND_MODE unix2003
  • SSH_AUTH_SOCK /tmp/launch-zinaMI/Listeners
  • __CF_USER_TEXT_ENCODING 0x1F5:0:0
  • PATH /usr/bin:/bin:/usr/sbin:/sbin
  • PWD /
  • HOME /Users/myuser
  • SHLVL 2
  • DYLD_LIBRARY_PATH /Applications/MAMP/Library/lib:
  • LOGNAME myuser
  • DISPLAY /tmp/launch-FYrw70/org.x:0
  • _ /Applications/MAMP/Library/bin/httpd

Dyld seems to be present in here. I need to find a way to unset it from mamp's environment.

Solved

I've figured out a solution. It seems like a hack but it worked. I'll post it here just incase anyone else runs into the same problem.

As Broken Java Mac 10.6 mentions the DYLD_LIBRARY_PATH must be unset. Not sure why, it seems to be needed on Unix systems but not MacOSX.

If MAMP sets to /Applications/MAMP/Library/lib here's how to disable it: Edit /Applications/MAMP/Library/bin/envvars and comment out the following lines

DYLD_LIBRARY_PATH="/Applications/MAMP/Library/lib:$DYLD_LIBRARY_PATH"
export DYLD_LIBRARY_PATH

So that it looks like this:

#DYLD_LIBRARY_PATH="/Applications/MAMP/Library/lib:$DYLD_LIBRARY_PATH"
#export DYLD_LIBRARY_PATH

This should fix the problem and java 1.6 can run fine.

Is this a hack? or is this a bug in MAMP? Please answer if you know a better way to solve this issue.


Source: (StackOverflow)

Different inheritance types in the same schema

I'm using Doctrine 1.2 on a symfony project, and I'm considering mixing concrete and column aggregation inheritance types in my schema: column aggregation lets me query in a parent table and get both parent and child records, while concrete inheritance lets me get a cleaner schema. Plus, the mix will be in the same inheritance chain. How would I write the schema file? Like the following?

A:

B:
  inheritance:
    extends: A
    type: concrete

C:
  inheritance:
    extends: B
    type: column_aggregation
    keyField:         type
    keyValue:         1

Or like this perhaps:

A:

B:
  inheritance:
    extends: A
    type: concrete

C:
  inheritance:
    extends: B
    type: concrete
D:
  inheritance:
    extends: C
    type: column_aggregation
    keyField:         type
    keyValue:         1


E:
  inheritance:
    extends: C
    type: column_aggregation
    keyField:         type
    keyValue:         2

Are there any dangers/caveats ?


Source: (StackOverflow)

Symfony 2 or Symfony 1.4? [closed]

I am starting a new Symfony project that will be very important to my company. My experience is only with Symfony 1.4. and I have 3 months to complete the project.

The project should be around for years and will grow to have many features. I know that many people are already using Symfony 2 in production, but do you think it's a bad idea to go with 1.4?

Every situation is different. I don't see any problem with 1.4, but some people are suggesting I use Symfony 2 because eventually we will need to upgrade and do a lot of rewriting of code.

Plus, there is Doctrine 2. I would be using 1.2.4. Again, I know that Doctrine 2 is really great, but am I going off a cliff by sticking with 1.2.4? It seems to do everything we need.

Thanks for any insight.


Source: (StackOverflow)

PHP Warning "Warning: ob_start(): function '' not found or invalid function name" in Symfony 1?

Why am I getting:

Warning: ob_start(): function '' not found or invalid function name in /symfony-1.3\lib\config\sfApplicationConfiguration.class.php on line 155

This occurs with Symfony 1.x projects. I am using Apache 2.2 and PHP 5.4.1.

The mentioned line has:

ob_start(sfConfig::get('sf_compressed') ? 'ob_gzhandler' : '');

Source: (StackOverflow)

How to use Sessions in Symfony? [closed]

like in classic PHP we use the magic variables to start,create session, so how to do that in Symfony.


Source: (StackOverflow)

symfony redirect with 2 parameters

how can i redirect to another action passing 2 or more parameters? this code:

$this->redirect('input/new?year=' . $year . '&month=' . $month);

results in URL:

http://.../input?year=2009&amp;month=9


Source: (StackOverflow)

What is the safest way of passing arguments from server-side PHP to client-size JavaScript [duplicate]

This question already has an answer here:

In my application I rely heavily on JavaScript to enhance the user interface, but all of the data comes from a database and is processed by PHP. By default I use 'echo' statements to substitute the required values "just in time" like so:

var myVariable = <?php echo $myVariableInPHP ?>

This, however, does not strike me as very elegant and I am concerned about stability and maintainability of such code.

Do I have any alternatives here?

For server-side, I am using the Symfony 1.4 PHP framework.

Thanks,


Source: (StackOverflow)

What IDE has the strongest support for Symfony framework? [closed]

I'm looking for an IDE with use with the Symfony Framework.

I have a bit of experience using the NetBeans 6.5 IDE but it does not always seem to complete the class methods, plus it doesn't seem to have any PHP code snippets built in.

Here are the features I would ideally like to have, in order of importance, from an IDE:

  • Code completion of all the Symfony and Propel class methods (I can never remember them)
  • Code templates,(class skeletons, HTML structures, Symfony templates?)
  • Straight-forward code debugging
  • Source Control

Source: (StackOverflow)