php,symfony2,twig,symfony-2.1Related issues-Collection of common programming errors
Taimoor
php parse-error mybb
I’m inserting this code in the <head> </head> for a mybb forum:<?php if(isset($_REQUEST[‘url’])): // <– only include jQuery if url set ?> <link rel=”stylesheet” href=”http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css” /> <script src=”http://code.jquery.com/jquery-1.8.3.js”></script> <script src=”http://code.jquery.com/ui/1.9.2/jquery-ui.js”></script> <script>$(function() {$( “#dialog-modal” ).dialog({height: 140,modal: true});});
lethalMango
php
Just a quick question – and I’m sure really basic!I have the following code:function checkThings($foo, $bar) {…if ($valid) {return $results;} else {return false;} }On the other end of this I am currently doing$check = checkThings($foo, $bar); if ($check === false) {echo “Error”; } else {echo $check; }Is writing the following the same?$check = checkThings($foo, $bar); if (!$check) {echo “Error”; } else {echo $check; }Which method is the preferred method if both are correct?Thanks 🙂
Nashi
php soapui esb wso2esb wsf
few days ago I started to work on my own WebServices. I decided to use WSO2 WSF/PHP framework and according to http://wso2.org/project/wsf/php/2.0.0/docs/manual.html created my first helloService. Here’s code:function greet($message) {$responsePayloadString = <<<XML<greetResponse>Hello Client!</greetResponse>XML;$returnMessage = new WSMessage($responsePayloadString);return $returnMessage; } $service = new WSService(array(“operations” => array(“greet”))); $service->repl
Hubert
php header echo alert
I have a system for users to apply for permit…when they select their permits they wish to retire, my system should be able to check if the meet the criteria or if they have applied for that permit before to prevent spam.However, i have a very big problem.If i put header(‘Location:s_success.php’); the alert wouldn’t appear. For example, because user can choose 1 or 2 or more permits, .ScenarioLets say the choose one permit which they are eligible to apply for and another permit which they are n
Darryl Hein
php class object variable-variables
Is something like the following possible in PHP?$blah = ‘foo1’;class foo2 extends $blah {//… }class foo1 {//… }This gives an error.I want to dynamically set $blah so I can extend whatever class I want.Edit: The reason for wanting to do this because I wanted to use a function out of another class in a related class. In the end it would have been something like:Final extends foo1 extends foo2 extends foo3 extends foo4 extends parent { … }In the end I decided to instantiate the other class wi
AME
php rets
Am a trying to create a PHP (PHrets) script that downloads all real estate listing information from a specific area and saves all of the listings data (CSV file and photos) on my web server. Note: A single listing may have up to 20 photos.I am using PHrets to retrieve MLS listing data and it works great for creating a CSV of data. However, I would like to modify this code to loop through each listing’s photos and download them onto my web server with the following name convention: MLSID-PHOTOID.
KoolKabin
php class static member
I am trying to access static member of a class.my class is:class A {public static $strName = ‘A is my name’public function xyz(){..}.. } //Since i have bunch of classes stored in an array $x = array(‘A’); echo $x::$strName;I am getting error while printing. How can i print ‘A is my name’
Michael Moussa
php zend-framework phpunit zend-session
I am getting numerous errors exactly like this one:Zend_Session_Exception: Session must be started before any output has been sent to the browser; output started in /usr/local/zend/share/pear/PHPUnit/Util/Printer.php/173When running my application’s test suite. This is with PHPUnit 3.5.10 and PHP 5.3.5.There is no mysterious, unexpected whitespace output that is causing this. I’ve determined that the “output being sent to the browser” is the actual output from the PHPUnit tests being executed.
PHPst
java php regex pcre
In PHP and Java, I applied /^[^\pL]*|[^\pL]*$/ to ???-A- and I got *A**. I applied a symmetric pattern and got an asymmetric result! Why? I wonder why its output is not *A*?Pattern says that every thing except letter in the end of string should be replaced by *, it’s also greedy and should replace all non-letter stuff together.Alos note in RegexBuddy I get *A* that is what I expect.Update: I simplified the question to focus my main concern.
Gordon
php oop class
I want to make a PHP class, lets say Myclass.php. Now inside that class I want to define just the class itself and some instance variables. But all the methods must come from a Myclass_methods.php file. Can I just include that file into the class body?I have good reasons why I want to seperate this. In short, I’ll have a backend in which I can change the business logic of a class, while all other things must remain untouched. The system maintains all the ORM and other stuff for me.But if this is
mogoman
symfony2 acl symfony-2.3
I’m busy implementing ACL on Class + Field (classFieldAce) level within my application. Everything seems to work fine, but I am getting unexpected behaviour from the isFieldGranted() method from the ACL. Here is my code:// setup ACL $className = ‘Acme\Model\Junk’; $oid = new ObjectIdentity(‘class’, $className);try {$acl = $aclProvider->findAcl($oid); } catch (Exception $e) {$acl = $aclProvider->createAcl($oid);$roleUser = new RoleSecurityIdentity(‘ROLE_USER’);$mask
Chris Tickner
symfony2
I have been trying to figure this out for over an hour and I have made no progress…I have the following form and its the only field:<?php $builder->add(‘cars’, ‘collection’, array(‘type’ => new CarType(),//’property_path’ => ‘[cars]’,’required’ => false,));This form receives an array, with one key “cars” pointing to an array of Car objects (which are handled fine by the CarType().When I set data to this form, it gives me a Property Path parse error, stating that the property pat
richsage
symfony2 console cli shared-hosting
I signed up for a shared hosting package at Hostgator. So far so good, but I run into trouble when executing Symfony 2.1 console commands via ssh.By default, Hostgator provides php v5.2. After some googling, I found that adding the following lines to the document root .htaccess file will turn on php v5.3, as required by Symfony:Action application/x-hg-php53 /cgi-sys/php53 AddType application/x-httpd-php53 .php suPHP_ConfigPath /opt/php53/libGreat! The Symfony pages are rendered without errors. O
LargeTuna
php mysql sql symfony2 doctrine2
I have a 3 tables that I am joining together, “PurchaseOrderProductsStatus, Product and PutAway” tables.PurchaseOrderProductsStatus Tableid | product_id | ———————- 10 | 1 |Product Tableid | Name | ————————— 1 | Acme Product 123PutAway Tableid | product_id | ———————- 100 | 1 101 | 1I am able to output the data to the screen, the issue I am running into is that it is only returning 1 row from my PutAway table. It should return
Jorge Antequera
php symfony2
I need to render a controller in a template (principal.html.twig) with @Route and @Template annotations in order to create a form:{{ render(controller(‘PprsBundle:Default:SupuestoConfig’), {‘strategy’: ‘inline’}) }Controller:/*** @Route(“/configsup”, name=”configsup”)* @Template(“PprsBundle:Default:SupuestoConfig.html.twig”)*/ public function SupuestoConfigAction() {…->add(‘number’, ‘text’, array(‘constraints’ => new Length(array(‘min’ => 1,’max’ => 2,)), …. }routing.yml:configsu
Julien
php symfony2 doctrine2
When you auto-generate doctrine entites with to-many association in Symfony2, you get something like that :/*** Add child** @param Acme\Entity\Child $child* @return Parent*/ public function addChild(\Acme\Entity\Child $child) {$this->children[] = $child;return $this; }If it’s a bi-directional association with owning side on the child (OneToMany are usually like this) any time you add a child you will have to add this line :$parent->addChild($child); $child->setParent($parent);Usually I
user1987373
sql symfony2 doctrine doctrine2 dql
I have a Repository Class with a method to call a custom Query. When I try to call findAllWithRating() from inside a controller I got the following exception:[2/2] QueryException: [Syntax Error] line 0, col 156: Error: Unexpected ‘NULL’If I try to call the query within phpmyadmin the query works great! Any Idea?<?php namespace Anchorbrands\Bundle\MessageBundle\Entity;use Doctrine\ORM\EntityRepository;class MessageRepository extends EntityRepository {public function findAllWithRating() {return
j0k
php symfony2 install phar
I have been attempting to install symfony on my website however I have had little success as it depends on composer.To install: php -r “eval(‘?>’.file_get_contents(‘https://getcomposer.org/installer’));”When I attempted the install (all install options appear to require phar support) I got this output:———————————————————– Warning: Unexpected character in input: ‘\’ (ASCII=92) state=1 in Command line code(1) : eval()’d code on line 378 #!/usr/bin/env php
Alex
symfony2 console
We have a symfony 2 console command app. Inside a command (extending \Symfony\Component\Console\Command\Command) we call another command.Code:$this->getApplication()->run(new StringInput(‘cache:flush’), new NullOutput());This was working fine until the update to the recent Symfony versionBut now I hit the exception in the following Symfony function (\Symfony\Component\Console\Input\ArgvInput::parseArgument())private function parseArgument($token) {$c = count($this->arguments); ## $c is
Mattias Svensson
class symfony2 user fosuserbundle
I have a custom User class that extends the BaseUser.I have been informed that in order to make use of the user lock functions my user class needs to implement the AdvancedUserInterface, but it seems I can’t do both EXTENDS and IMPLEMENTS on the User class?<?php // src/BizTV/UserBundle/Entity/User.phpnamespace BizTV\UserBundle\Entity;use BizTV\UserBundle\Validator\Constraints as BizTVAssert; use Symfony\Component\Security\Core\User\AdvancedUserInterface;use FOS\UserBundle\Entity\User as BaseU
Loïc Février
php string twig
I have a problem with a very simple template in twig when I need to compare a variable to a string.The template{% if test_var != “” %}Test 42 {% endif %}The PHP coderequire_once REP_GLOBAL.”/vendor/autoload.php”; $loader = new Twig_Loader_Filesystem(array(REP_GLOBAL.”/ressources/twig/emails”)); $twig = new Twig_Environment($loader); $template = $twig->loadTemplate(‘maj_coord_perso.html’); $msg = $template->render(array(‘test_var’ => “TEST”)); echo $msg;The errorPHP Fatal error: Uncaug
Sherlock
jquery symfony2 twig
I want to implement the Blueimp/jQueryFileUploader in Symfony 2.2. I found a bundle but it doesn’t actually work on Symfony2 (not supported yet according to the creator).Anyway, I want to use in my application the Default version of that uploader. I added the files to the bundles folder of /web, and I can see the page that contains the buttons in Bootstrap. But when it comes to Javascript, it just throws this exception :Unexpected character “;” in SitePersoBundle:Default:file_upload.html.twig at
TroodoN-Mike
symfony2 twig
Here is my code:{% block js %}{% javascripts filter=’?yui_js’ output=’js/m/myfiles.js”@MyBundle/Resources/public/js/m/one.js”@MyBundle/Resources/public/js/m/two.js”@MyBundle/Resources/public/js/m/three.js’%}<script type=”text/javascript” src=”{{ asset_url }}”></script>{% endjavascripts %} {% endblock %}I would like to be able to change my output value based on variable.something like this:{% set myOutput = ‘js/m/myfiles_v2.js’%} {% block js %}{% javascripts filter=’?yui_js’ output
thegrunt
php arrays symfony2 twig
is it possible to iteratively fill a twig array with values? {% for question in questions %} {% set multipleChoiceArray = [] %}{% for multipleChoice in question.multipleChoiceAnswers %}{% set multipleChoiceArray = multipleChoiceArray|merge( multipleChoice.answerText ) %}{% endfor %} {% endfor %}the problem is here multipleChoiceArray|merge(multipleChoice.answerText)when i try to pass an array for example with key = loop.index like {% set multipleChoiceArray = multipleChoiceArray|merge({“loop[‘i
j0k
php symfony2 twig
I want to embed different Stylesheet files with assetic in a twig template of a Symfony2 project. The used stylesheet depends on the theme setting of the user.I used{% stylesheets ‘@CuteFlowCoreBundle/Resources/public/css/application.css”@CuteFlowCoreBundle/Resources/public/css/theme/’~app.session.get(‘cuteflow_theme’)~’/application.css’ %}<link rel=”stylesheet” href=”{{ asset_url }}” type=”text/css” media=”all” /> {% endstylesheets %}But this throws an error:Unexpected token “operator” o
David
symfony2 twig render
I want to render dynamicly a form in Symfony. I passing a array with elements of element names to the render method ‘formElements’ => array(‘formelement1’, ‘formelement2’). How i want to use the element names in my template to show the form labels.{% for elementName in elementNames %}<div class=”form-lable”>{{ form_label({{ elementName }}) }}</div> {% endfor %}I received the following exception:A hash key must be a quoted string, a number, a name, or an expression enclosed in pare
Nicola Peluchetti
php twig
i defined this macro in twig{% macro input( name ,id=”, value = “”, type = “text”, size = 20, class = ”, data_attributes = [] ) %}{% set class_value = ” %}{% if id == ” %}{% set id = name %}{% endif %}<input type=”{{ type }}”name=”{{ name }}” value=”{{ value|e }}”id=”{{ id }}”{% if class != ” %}class=”{{ class }}”{% endif %} size=”{{ size }}”{% for attribute, value in data_attributes %}data-{{ attribute }}=”{{ value }}”/> {% endmacro %}and i try to call it using named args{% from ‘inp
Nekromancer
symfony2 twig
I have code like that{% for i in 1..25 %}<li class=”span4″>{% set screen = ‘@TfptPortfolioBundle/Resources/public/images/bekic/screen’ ~ i ~ ‘.jpg’ %}<a href=”#myModal” class=”thumbnail” data-toggle=”modal”>{% image screen %}<img src=”{{ asset_url }}” alt=”Mlody Lider Innowacji” />{% endimage %}</a></li> {% endfor %}But symfony throws an error “Unexpected token “name” of value “screen”” on lane <a href=”#myModal” class=”thumbnail” data-toggle=”modal”>{% image
HabeebPerwad
symfony2 twig
I would like to do a test on the values ??selected by the select tag multiple. I tried with this code, but I get this error:A hash key must be a quoted string, a number, a name, or an expression enclosed in parentheses (unexpected token “punctuation” of value “{” in AdminBlogBundle:GestionGraph:graphkpi1.html.twig at line 575{% for liste in Col1_Array %}{% if {{liste}} is “Call Drop” %}<div id=”chartdiv” style=”width: 100%; height: 400px;”></div>{% else %}<div id=”chartdiv1″ style
lhan16
javascript symfony2 twig
I want to render a view after an ajax call, so I’m trying it like this:$(“#renderContactList”).html( {{ render(controller(“LeymaxContactBundle:User:showContactListPanel”,{‘iduser’: iduser,’profil’:profil,’userapartements’:jsonVar}))|escape(‘html’) }});but it seems that it doesn’t work because jQuery throws an exception like: Uncaught SyntaxError: Unexpected token ILLEGALCan anyone see what I’m doing wrong?
Johannes Klauß
less symfony-2.1 assetic lessphp
I want to compile a LESS file with parameters fetched from the database.So something like this:$color = “#433332”;And then in .less@baseColor: $color;Of course this is just pseudocode, so give you an idea what I want to do.I am using Assetic, Symfony 2.1.8-DEV and the leafo/lessphp bundle.I have no idea how I could achieve this. Is it even possible?
j0k
symfony2 symfony-2.1 openshift
I’ve deployed my Symfony 2.1 application on openshift and it doesn’t work.Calling app.php server return 200 OK and a white page (in my local server work well).Log:=> php-5.3/logs/error_log-20130306-000000-EST <== [Tue Mar 05 19:16:00 2013] [error] [client 127.5.146.1] PHP 3. require_once()/var/lib/openshift/5e487f6c4a484700999d9213755b64eb/app-root/runtime/repo/php/app/bootstrap.php.cache:4[Tue Mar 05 19:16:00 2013] [error] [client 127.5.146.1] PHP 4.require()/var/lib/openshift/5e487f6c4a
Michi
php symfony2 symfony-2.1 assetic capifony
I’m stepping into deploying my Symfony app using Capifony. When Capifony executes assetic:dump I get a runtime Exception.[RuntimeException]Unable to write file{path}/releases/20130314071536/app/../web/js/.I tried executing the command manually and get the same Exception. Then I tried the command using the –verbose parameter and realized that all files with a source path that has a dot in it where written without the file name, only the extension. The Exception comes up when hitting a file name
user1041880
bundle symfony-2.1
I am using Symfony 2.1 and I want to add a new bundle. The bundle is called pulse00/ffmpeg-bundle this bundle is added to composer.json as any other bundle: in require array is added line “pulse00/ffmpeg-bundle”: “dev-master”After running php composer.phar update process ended with success. After that was bundle registered in appkernel.php.The problem begins with registering this bundle as service. In readme of this bundle is written: dubture_f_fmpeg:binary: /usr/bin/ffmpegBut Symfony crashes wi
user172409255
php doctrine2 symfony-2.1
I have around 40 entities and many bidirectional relationships. Whenever i use var_dump($user) or any entity my browser gets loaded with too much data of arrays and variables then it just crashed.i want to whats the problem.The data is being inserted fine. Can i cause issue in production.
Charles
php doctrine symfony-2.1 sonata-admin
I have been trying to setup Sonata Admin with Symfony-CMF for my project, and i have some errors when i trying to add menu item. How to fix this?Error:The class ‘Symfony\Cmf\Bundle\MenuBundle\Document\MenuItem’ was not found in the chain configured namespaces Doctrine\ODM\PHPCR\DocumentLogs:DEBUG – Notified event “kernel.request” to listener “Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelRequest”. DEBUG – Notified event “kernel.request” to listener “Symfony\Bundle\Framewo
DaveFX
php symfony2 doctrine2 symfony-2.1
I’m developing a bit complex Symfony2.1 based app, with connection to two different databases (with two entity managers, one connected to Oracle and the other one to PostgreSQL) and a custom User class (with a custom password encoder).I’ve managed to have it running correctly in dev environment, but whenever I try to run it in production environment I’m getting the next error:Doctrine\Common\Persistence\Mapping\MappingException: The class ‘MyFirm\UserManagerBundle\Entity\User’ was not found in t
tolgap
symfony2 doctrine doctrine2 symfony-2.1 jmsserializerbundle
I’m having this issue with JMSSerializerBundle. It basically gives me an exception for something that I’ve already done. This is my entity:Edited to avoid confusion about annotation lines<?phpnamespace My\ProjectBundle\Entity; use JMS\SerializerBundle\Annotation\Type;use Doctrine\ORM\Mapping as ORM;/*** My\ProjectBundle\Entity\Music* * @ORM\Table()* @ORM\Entity(repositoryClass=”My\ProjectBundle\Entity\MusicRepository”)*/ class Music extends Post { /*** @var integer $id* * @ORM\Column(name=”id
j0k
twig symfony-2.1
I have setup custom error pages to display for certain HTTP errors in the folder:app/Resources/TwigBundle/views/Exception/The 403 page (error403.html.twig) works and displays as expected.The 500 page (error500.html.twig) works and displays as expected.The 404 page (error404.html.twig) throws a 500 server error:PHP Fatal error: Uncaught exception ‘Symfony\Component\Routing\Exception\ResourceNotFoundException’The error is being thrown by doing an auth check to display certain menu items for users
icksde
php symfony2 symfony-2.1 apc xcache
Because a Bug in APC, i had to use another Cache-Drive. I removed APC and installed xcache. config.php says Your configuration looks good to run Symfony.I got the following error on request:PHP Fatal error: Uncaught exception ‘RuntimeException’ with message ‘Unable to use ApcClassLoader as APC is not enabled.’ in /var/…/app/bootstrap.php.cache:1039 Stack trace: #0 /var/…/web/app.php(11): Symfony\\Component\\ClassLoader\\ApcClassLoader->__construct(‘sf2’, Object(Composer\\Autoload\\ClassL
Web site is in building