symfony2,vps , Setup VPS with a Symfony2 project from git repository


Setup VPS with a Symfony2 project from git repository

Question:

Tag: symfony2,vps

I have a:
- VPS with LAMP stack
- local symfony2 project (git)
- bitbucket repository

What do I need to do to properly setup my project in the production evironment?

Folder structure/permissions?
Can I simply clone the repository in the public folder? (I don't think so)

P.s. I've already read the deployment guide on the symfony2 website, but I didn't find it very useful


Answer:

Here are my deployment steps:

  1. git clone project
  2. go to project directory
  3. php composer.phar install (and if composer is not in the project directory curl -sS https://getcomposer.org/installer | php)
  4. app/console doctrine:database:create
  5. app/console schema:update --force
  6. app/console assets:install web --symlink
  7. chmod 777 -R app/cache app/logs web/media/cache (I often use liip imagine, it resizes photo in web/media/cache)
  8. point the virtual host of apache to the web directory of my project. And you are done.

you might want to enable mode rewrite in apach (a2enmod rewrite) I think this covers everything.


Related:


Unable to configure Symfony (3rd party) bundle


php,symfony2,rss
I am faily new to Symfony and I am trying to setup a third party bundle that reads RSS feeds and then insert them into database. The third party bundle I am trying to use is called rss-atom-bundle After reading the instructions I can get the RSS feeds however I...

Redirecting all ip to maintenance page except some ips


apache,.htaccess,symfony2
When releasing new versions of my Symfony project, I need to redirect all external ip addresses to a maintenance.html page (which lives into symfony web directory) using apache. Here is the virtualhost file configuration I've created for this purpose but: When I go from an external ip I get 403...

Logs an entire array using Monolog [closed]


php,symfony2,monolog,symfony-2.6
Is there any way to log an entire array using Monolog? I have been reading several docs but didn't find a way to log the entire array in a readable format, any advice? Docs I've read: Monolog, how to log PHP array into console? http://symfony.com/doc/current/cookbook/logging/monolog.html https://www.webfactory.de/blog/logging-with-monolog-in-symfony2 ...

Unique Entity Error message


api,symfony2,exception-handling,doctrine
I have a user entity which have some unique fields. The code bellow shows you how I defined it. /** * @UniqueEntity(fields={"login"}, message="UNIQUE ERROR MESSAGE") */ ...... /** * @var string * * @ORM\Column(name="login", type="string", length=255, unique=true) */ private $login; Developping an API, I would like to be able to...

How adapt the path to the previous and next article


php,symfony2
I am looking for a solution to access in the current article to the previous(<<) or the next article(>>) at the end of the page of an article. I thought to get the current paramater of the url with this : {{ dump(app.request.attributes.get('_route_params')) }} and inject in the path with...

Symfony2: ajax call redirection if session timedout


ajax,symfony2,session
I have a working dashboard with ajax request. I fire an ajax request on some events which will update a part of the dashboard. But if the session has expired, the part will be refreshed with the login page. How can i do a redirection after the ajax call if...

Symfony2/Twig - iterate over select options


php,symfony2,twig
Usual way of displaying select field is to call {{ form_row(form.doctor_service_id, {'attr':{'class':'form-control'}}) }} I would like to perform two things: Check if this field is actually a select field Iterate over every option (value, name). I know how twig iterator works, I just don't know how to access select options...

Symfony one-to-one, unidirectional relation


symfony2,doctrine2
I have two entities. User and Contact. User and contact have the same property phone_number. I would like to get all contacts with user object if its exists. It is also possible that the same phone number exists in contact table but it doesn't exist in user table. Below is...

How to write and use Monolog handlers and channels


php,symfony2,monolog,symfony-2.6
I have read some docs here but still not clear to me how to write and use a custom Monolog handler and channel. Let me explain a bit what I want to achieve. I have a custom function and I want that log to be logged into a file called...

I can't do update with an entity in my select symfony 2


symfony2
$builder ->add('tecnicoId', 'entity', array( 'class' => 'MainHomeBundle:Tecnicos', 'property' => 'nombre', 'expanded' => false, 'multiple' => false )) ->add('cambiar', 'submit') ; controller $form = $this->createForm(new ServicioseditType(), $datos); $form->handleRequest($request); $em = $this->getDoctrine()->getManager(); $em->flush(); return $this->render('MainHomeBundle:Admin:editserv.html.twig', array("form"=>$form->createView())); view twig {{ form_errors(form.tecnicoId) }} {{...

Symfony/Twig how to render a Route set by anotation?


php,symfony2,routing,twig,url-routing
Let's say I have this code in a controller: <?php namespace Foo\BarBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Sensio\Bundle\FrameworkExtraBundle\Configuration as Mvc; /** * @Mvc\Route("/foo/bar") */ class TestController extends Controller /** * @Mvc\Route("/test/{id}", requirements={"id" = "[0-9]{1,6}"}) * @Mvc\Template * * @return view */ public function testAction($id) { return array('test' => $id); } } How...

plesk when upgrading php, will this break everything?


php,centos,server,vps,plesk
I'm running a VPS with centOS, plesk 12 and PHP5.3. I'm looking to upgrade to a more recent version of php but without taking down all my sites running on that server. I've tried through the plesk GUI and got to this point which is ambiguous to what it will...

Force Uppercase on Symfony2 form text field


php,forms,symfony2
I've inherited a Symfony2 project that has a form built as such: $builder ->add('Status', 'choice', array( 'choices' => array('' => '', 'PASS' => 'PASS', 'FAIL' => 'FAIL', 'INCOMPLETE' => 'INCOMPLETE', 'DROPPED' => 'DROPPED',), 'required' => FALSE, )) ->add('First_Name', 'text', array('label'=>'First Name', 'required' => FALSE)) ->add('Last_Name', 'text', array('label'=>'Last Name', 'required' =>...

symfony twig render dynamic twig code


symfony2,twig
In my symfony2 action, i have: $twigCode = '<li>{{ data.value }}</li>'; //In database $datas = array(array( 'value' => 'line 1'), array( 'value' => 'line 2')); return $this->render( '...List.html.twig', array( 'twigCode' => $twigCode, 'datas' => $datas ) ); In my twig template, i want something like: <ul> {% for data in...

ClassNotFoundException Symfony UserBundle


symfony2,fosuserbundle
I'm developping a website on Symfony2, I want to intergrate FOSUserBundle. I am using Doctrine ORM User class. I've followed the installation steps but I got this error: ClassNotFoundException in AppKernel.php line 21: Attempted to load class "FOSUserBundle" from namespace "FOS\UserBundle". Did you forget a "use" statement for another namespace?...

Deserializing or parse XML response in Symfony2


php,xml,symfony2,deserialization,jmsserializerbundle
I am calling a API method through cURL and I got this response: <?xml version="1.0" encoding="UTF-8"?> <jobInfo xmlns="http://www.force.com/2009/06/asyncapi/dataload"> <id>75080000002s5siAAA</id> <operation>query</operation> <object>User</object> <createdById>00580000008ReolAAC</createdById> <createdDate>2015-06-23T13:03:01.000Z</createdDate> <systemModstamp>2015-06-23T13:03:01.000Z</systemModstamp> <state>Open</state>...

Symfony2: changing the request class and updating the test environment


php,symfony2,request,phpunit
I have modified the base Request class of my application as explained in the accepted answer of this question. It works very well, except when launching my functional tests, I get the following error: Controller "My\Bundle\AppBundle\Controller\MyController::searchAction()" requires that you provide a value for the "$request" argument (because there is no...

Symfony2 Catchable Fatal Error: Argument 1 passed to entity Catchable Fatal Error: Argument 1 passed to entity


php,forms,symfony2,entity,symfony-2.6
I got this error and I'm stuck since many hours Catchable Fatal Error: Argument 1 passed to Thinking\ThinkBundle\Entity\InYourMind::setThinkFriend() must be an instance of Thinking\ThinkBundle\Entity\InYourMindFriend, array given, called in /var/www/html/thinkroulette/vars/vendor/symfony/symfony/src/Symfony/Component/PropertyAccess/PropertyAccessor.php on line 410 and defined I searched for this issue and lots of results came up but I wasn't capable to...

Using crontab to call wget every 5 minutes


php,symfony2,crontab,wget
I am working on a project where the wget and crontab are used to run a process in the background. I have a php file named "Hello.php" that I want to run this every 5 minutes. I have found that if I want to have a cron job run every...

Adding own action to SonataAdminBundle dropdown menu


symfony2,sonata
We use the SonataAdminBundle with our Symfony2 application. When editing an entity I want to add an own action to the dropdown menu which is located in the top right corner, but I have no idea how this works. I know I can add own routes via configureRoutes(RouteCollection $collection) and...

wkhtmltopdf on openSuSE: cannot connect to X server


php,symfony2,pdf-generation,twig,wkhtmltopdf
I need wkhtmltopdf on openSuSE. I have installed it via the repository. The version is 0.12.1. To render HTML with Symfony, I use the KnpSnappyBundle. By rendering a twig template, I got the following error message: The exit status code '1' says something went wrong: stderr: "wkhtmltopdf: cannot connect to...

Symfony 2 unable to pass entity repository to form


php,forms,symfony2,runtime-error
I have a form with a drop down and a set of checkboxes, i've used entity form field type to get the values via DB. it works with one of the entity but not with the other. i have this code seperately inside AddBadgesType there is NO AddBadges entity <?php...

Symfony2 move app.php from web directory to root directory


symfony2
I moved app.php from web directory to root and i change the following two lines: $loader = require_once __DIR__.'/app/bootstrap.php.cache'; require_once __DIR__.'/app/AppKernel.php'; Also i move .htaccess file from web directory to root , my problem is that now the system cannot find JavaScript and CSS files....

order attribute of an object in Synfony


php,symfony2
I would like to reorder the attribute (COMMENTS) of my object (instance of ARTICLE) after I retrieve it from the DBB. Is this possible? My object is ARTICLE and it is linked to COMMENTS (which is defined as a collection in entity article) I know I can order through the...

Symfony2 relationship between two entities


php,mysql,entity-framework,symfony2
I want to make a relationship between two entities but for some reason I am getting NULL on one of the values... So in my skin entity I have an email_registration_id field with the relationship : /** * @ORM\ManyToOne(targetEntity="Project\UserBundle\Entity\Email") * @ORM\JoinColumn(name="email_registration_id", referencedColumnName="id") */ protected $email_registration_id; /** * Set email_registration_id *...

Store entity from session doesn't work => $em->persist()


php,symfony2,doctrine2
at first: Sorry for my poor english :-) A beginner need help! I have 3 entities/tables: Tables: contact_person id, title, firstname, surname, adress_id address id, street, zip, city, country_id country (fix values) id, name, code 1, Austria, AT 2, Germany, DE ... Entities: /** * ContactPerson * * @ORM\Table(name="contact_person") *...

Setting cookie for AngularJS translate locale using PHP


php,angularjs,symfony2,angular-translate
My app uses Symfony and AngularJS. I have translations some with Symfony itself and some with AngularJS angular-translate. How do I set a cookie or session variable to change language for AngularJS from PHP?

Dependencies in forms Symfony2


php,forms,symfony2,events,entities
I'm working on a webapplication in Symfony2. I came to a point in which I need some advice/explanation from some one more advanced in Symfony. I have a part of my database that is set up as follows: I have cards that belong to a card attribute set and consists...

Remove automaticaly entity in BD when choice value not selected (or null selected)


php,forms,symfony2,doctrine
I would like to know if symfony/doctrine can manage automaticaly the fact that instead of setting the value of my entity to null it could symply remove it. (by removing it I mean the records where the value equal null) exemple: I have a PICTURE entity linked to a VOTE...

Validation of a form before submission


php,validation,symfony2,form-submit
Using Symfony, version 2.3 and more recent, I want the user to click on a link to go to the edition page of an already existing entity and that the form which is displayed to be already validated, with each error associated to its corresponding field, i.e. I want the...

Symfony\Component\Config\Exception\FileLoaderLoadException] error


php,symfony2,twig,swiftmailer
Hi I stumble upon this error everytime I want to run my Symfony application from console. Therefore I am unable to use this symphony app at all. Please help me with your knowledge. [Symfony\Component\Config\Exception\FileLoaderLoadException] Unable to parse at line 9 (near "mailer_transport="gmail"") in /opt/lampp/htdocs/symblog.dev/app/config/parameters.yml (which is being imported from "/opt/lampp/htdocs/symblog.dev/app/config/config.yml")....

OAuth HwioBundle, different socialNetWork


php,symfony2,oauth,hwioauthbundle
I work to projekt in Symfony wich have regisrtation HWIOBundle for different social network. If user enter for example linkedin and some time for github I has two user in database. Who knows how to do was one?

Set Auth Token manually for different firewall


symfony2
My application has 2 security firewalls "admin" - used by internal staff "account" - used by customers. Previoly I had one action under the account firewall, the action in the controller looks something like this. $user = //get user somehow $token = new UsernamePasswordToken($user, null, 'account', $user->getRoles()); $this->get('security.token_storage')->setToken($token); With this...

comparison operator is not working in twig


php,symfony2
problem in comparing dates in twig. case if event is ongoing or is about to begin within 7 days. twig code {% set event_startdate=data.detailes.data.event.event_startdate|date("d-m-Y")%} {% set event_enddate=data.detailes.data.event.event_enddate|date("d-m-Y") %} {% set upcoming_days =daysdiff(event_startdate)|date('d-m-y') %} {% set stdate= "now"|date('d-m-y') %} {% if event_startdate >stdate and event_startdate < upcoming_days %} // condition...

Symfony Crawler: how to check that a link to a particular page exists


php,symfony2,phpunit,functional-testing
I'm writing some functional tests and i want to verify that the Edit link exists on the page if the user is logged in. The link is a simple <a href="/profile/22/edit">Edit</a>. How can I filter it using the Crawler component of Symfony? One solution is this: $this->assertEquals(1, $crawler->filter('html:contains("<a href="/profile/22/edit">")')->count()); But...

Symfony Entity query builder that checks for free spots


php,mysql,symfony2,doctrine2,dql
First off all: I know the title isn't helping, but it's the best I can think of. So I've got two entities in Symfony one is called Team and the other one Slot the Slot entity has a name, a start and end date and all that stuff. Besides that...

Symfony2 service unable to find template


php,email,symfony2,templates,twig
I've just pulled an all-nighter trying to get this to work, and I'm probably missing something foolish, but help me out. I have a symfony2 service which sends emails. I have injected the @templating service into my service's constructor like so: services.yml order_service: class: AppBundle\Services\OrderService arguments: [ "@doctrine.orm.entity_manager", "@mailer", "@templating"...

How to create a console command in Symfony2 application


php,symfony2,symfony-2.6,symfony-components,symfony-console
I need to create a console command for a Symfony2 application and I read docs here and here though I am not sure what of those I should follow. So this is what I did. Create a file under /src/PDI/PDOneBundle/Console/PDOneSyncCommand.php Write this code: namespace PDI\PDOneBundle\Console\Command; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use...

Class inheritance in Symfony2


php,symfony2,doctrine2
I'm a bit confused about an error that I'm getting: Undefined method 'getAsArray'. The method name must start with either findBy or findOneBy! getAsArray() is a method in my repository class, it's called in PostsController.php like so: $categoriesList = $this->getDoctrine()->getRepository('AirBlogBundle:Category')->getAsArray(); CategoryRepository.php is defined like this: namespace Air\BlogBundle\Repository; class CategoryRepository extends...

Symfony 2 - Class “Mingle\StandardBundle\Entity\Product” is not a valid entity or mapped superclass


php,symfony2,doctrine,entity,bundle
I created a Product.php file in my bundle Mingle\StandardBundle\Entity like this: <?php namespace Mingle\StandardBundle\Entity; use Doctrine\ORM\Mapping as ORM; /* * @ORM\Entity * @ORM\Table(name="product") */ class Product { /* * @ORM\Column(type="integer") * @ORM\ID * @ORM\GeneratedValue(strategy="AUTO") */ protected $id; /* * @ORM\Column(type="string",length=100) */ protected $name; /* * @ORM\Column(type="decimal",scale=2) */ protected $price; /*...

Update session in symfony2 for shoppingg cart


php,symfony2,symfony-2.1,php-5.3,symfony-2.3
I have the following code : public function addAction(Request $request){ //Get submited data // Get Value from session $sessionVal = $this->get('session')->get('aBasket'); // Append value to retrieved array. $aBasket = $request->request->all(); if(count($sessionVal) > 0) { foreach ($sessionVal as $key=>$value) { if($aBasket['product_id'] == $sessionVal[$key]['product_id']) { $sessionVal[$key]['product_quantity'] = $sessionVal[$key]['product_quantity'] + $aBasket['product_quantity'];...

Symfony2 creating and persisting entity relationships


php,mysql,symfony2,doctrine2
I have two entities Skin and Email. I want Email to be a part of the Skin entity, however I can't use the console to update schema automatically right now, and that is probably why I can't get the relationship to work. So I want to store all the Emails...

With a OneToMany relation between entities, how create the right queryBuilder with Doctrine (on the Inversed Side entity)


php,symfony2,doctrine2,one-to-many,query-builder
I have these 3 entities in my symfony2.6 project: Compteurs.php class Compteurs { /** * @var \PointsComptage * * @ORM\ManyToOne(targetEntity="PointsComptage", inversedBy="compteurs") * @ORM\JoinColumns({ * @ORM\JoinColumn(name="pointscomptage_id", referencedColumnName="id") * }) */ private $pointsComptage; /** * @var \Doctrine\Common\Collections\Collection * * @ORM\OneToMany(targetEntity="ParametresMesure", mappedBy="compteurs") */ private $parametresMesure; ParametresMesure.php: class ParametresMesure { /** * @var Compteurs...

AngularJS execute some action in all application instances


angularjs,symfony2
I have AngularJS app called myApp. It has several controllers which are used in different pages (website is based on Symfony so page reloads happens sometimes). I need to execute some lines of code in every controller. how do I do that without duplicating that code?

Symfony/Twig radio style formbuilder


php,symfony2,twig,formbuilder
I need to style each of radio button using Symfony form builder. This is my part of my createFormBuilder: ->add('categoryId', 'entity', array( 'class' => 'MyBundle:Category', 'property' => 'name', 'required' => false, 'expanded' => true )) And in my twig template: {% for child in form.categoryId %} <div class="radio i-checks col-md-3">...

Symfony files which are included in CSS are not found when using assetic


css,symfony2,twig,assetic
I'm using Symfony with Twig and I use assetic. The problem is that my CSS file includes other CSS files like that: @import url(ie8.css); @import url(blocks.css); @import url(plugins.css); @import url(app.css); And these files are not found when webpage is displayed. Same happens with fonts and images. How do I solve...

Symfony change validation message globally


php,symfony2,symfony-2.3
Is there a way to change the basic validation error message to one I need for all entities at once? Currently using Yaml config for every entity, but it's not a way. CF\MyBundle\Entity\User: properties: email: - Email: message: e-mail no válido - NotBlank: message: Campo obligatorio username: -NotBlank: message: Campo...

WebTestCase, Silex and $_GET


symfony2,silex,web-testing
I'm experiencing some issues on a WebTestCase using Silex: on one of my controller's action, I need a parameter passed through a normal $_GET (I have to as it's an URL, and Apaches interprets the %2F if it's outside of the query string -- see Url Variables with %2f not...

Setup VPS with a Symfony2 project from git repository


symfony2,vps
I have a: - VPS with LAMP stack - local symfony2 project (git) - bitbucket repository What do I need to do to properly setup my project in the production evironment? Folder structure/permissions? Can I simply clone the repository in the public folder? (I don't think so) P.s. I've already...