How to run multiple versions of Symfony PHP Framework - php

I have several web projects built with Symfony v1.0, but I am excited by the new features in Symfony version 1.4 (Improved security, native email support and improved performance).
How can I continue to develop my 1.0 projects but also create a testing environment for version 1.4?

Guide to Installing Multiple versions of Symfony
Thankyou to Guillaume Flandre for pointing it out, there is a fantastic article written by eHabib on SymfonyNerds.com - http://symfonynerds.com/blog/?p=123
Here is the basic outline, read the whole article here.
Step 1 - Un-install Symfony via PEAR
Step 2 - Setup a structure for Symfony: Install symfony in /usr/share/php/symfony
Step 3 - Checkout each Symfony version you need
Use SVN checkout to grab each Symfony version. Put these in a different folder under the base Symfony directory.
Step 4 - Create symbolic links for each version
Create and test symlinks for each version of Symfony. Lets place these in the standard bin directory
Step 5 - Creating a new project
Use the relevant Symfony command. For example, to create a Symfony 1.0 project:
sudo symfony10 init-project test1
sudo symfony11 generate:project test11
sudo symfony12 generate:project test12
Step 6 - Check in the project Config to ensure its picked up the right version.

This link should be useful: http://symfonynerds.com/blog/?p=123
It points to an article named: Your complete guide to running multiple Symfony versions on the same environment
It's fairly easy to do.

As also said in the article, I define it in lib/vendor as svn:externals: symfony http://svn.symfony-project.com/branches/1.2
So there's no symfony to be installed on the server at all and you can use as many versions without influence on other apps.

Related

What does a recipe mean in the Symfony PHP framework?

I jsut started learning about the framework symfony
What does a recipe mean in the Symfony PHP framework?
what is a flex ?
Update :
https://symfony.com/doc/current/quick_tour/flex_recipes.html#flex-recipes-and-aliases
And second, Flex installs a recipe for symfony/twig-bundle. What's a recipe? It's a way for a library to automatically configure itself by adding and modifying files. Thanks to recipes, adding features is seamless and automated: install a package and you're done!
A recipe is a file returned by Symfony Flex which contains information (instructions) about how to modify the require, update, and remove commands of Composer. Essentially, recipes enable Symfony to automate the installation, update or removal of plugins in Symfony applications. For clarity, plugins are called bundles in Symfony lingo.
Symfony Flex is a Composer plugin designed for Symfony. This plugin helps to automate the installation, update or removal of Symfony bundles. Prior to Symfony Flex, after installation of a bundle for instance, you may need to perform additional manual configurations in some Symfony files in order to make use of the bundle in your application. With Flex, you install a bundle and Symfony automatically updates your file system and your bundle is ready for use in your application
Symfony flex also helps to install Symfony bundles using aliases for the specific bundles. For instance, prior to Symfony Flex, to install the SwiftmailerBundle, you have to execute composer require symfony/swiftmailer-bundle but with Symfony Flex, there is an alias composer require mailer which installs the same bundle.
So back to Recipes as files. Let's consider an example of the installation of the SwiftmailerBundle. If Symfony Flex is installed, before the Symfony application tries to execute composer require mailer, it first sends that command to the Symfony Flex server. In this case, Symfony Flex recognizes that composer require mailer is an alias for composer require symfony/swiftmailer-bundle so Symfony Flex will return a file (called a Recipe) to the Symfony application. This recipe will contain the actual composer command composer require symfony/swiftmailer-bundle to install the bundle, in addition to other post installation instructions for that bundle (if any).
Note that without Symfony Flex, the Symfony application will simply execute the command composer require mailer which will return an error because composer does not recognize a package with such installation command.
An example post installation instruction could instruct the Symfony application to modify a configuration file in the application with some configuration instructions, in order to get the bundle ready for use. This means the developer doesn't need to manually go to the configuration file and make changes in order to use the bundle, as was the case before Symfony Flex.
From Symfony 4.0, Flex is used by default (though optional). More information on Symfony Docs
From flex.symfony.com:
Symfony Flex is the way to manage Symfony applications.
It is based on Symfony Recipes, which are a set of automated
instructions to integrate third-party packages into Symfony
applications.
My own explaination:
With Composer you are able to add code components (bundles) to your Symfony project. Except the php code you have to add configuration, routes and assets for example in different configuration files or direcories. With "Flex recipes" this may happen automatically. This makes installing 3th party bundles more easy and quicker.

Symfony Native Debian

I installed symfony 2.8 on debian 9. Using native packages from the link repository.
Debian9 Package Symfony
Installed several components that use symfony, for example doctrine, twig, asset, etc.
In debian they were divided between /var/lib/dpkg and /usr/share folders.
In /var/lib/dpkg it is displayed that in the info folder are the .list of each component.
Result folder info
I searched for related information to make a "hello world" by displaying the native symfony and it's really little or nothing I got.
I have used and implemented projects in symfony in a traditional way with versions 2.8, 3.x. And I really can't emulate it with the native, as you would normally work.
Has anyone managed to deploy symfony natively?
Any help or tip will be welcome.
Thank you in advance.
Package from debian seems to install symfony 2.8 and the docs for this are:
https://symfony.com/doc/2.8/best_practices/creating-the-project.html
Simply by using:
symfony new blog
this should generate a basic app for you and then you should run
php app/console server:run
and if you visit http://localhost:8000/ in your browser you should see your app according to
https://symfony.com/doc/2.8/setup.html

How can I specify the symfony version of my project in netbeans?

I am trying to create a symfony2 project, with the symfony2.8 version. However whenever I create a symfony project in netbeans I cannot find where to specify the version of symfony and it always creates a symfony3 project. Is there any way to tell netbeans to use the symfony2 version instead of 3?
I'd save yourself the headache and time of trying to figure that out, and instead use the Symfony recommended way.
php -r "readfile('https://symfony.com/installer');" > symfony
# for example, if WAMP is used ...
">c:\> move symfony c:\wamp\bin\php
# ... then, execute the command as:
">c:\> symfony
# moving it to your projects folder ...
">c:\> move symfony c:\projects
# ... then, execute the command as
">c:\> cd projects
">c:\projects\> php symfony
https://symfony.com/doc/current/setup.html
Net-beans will still recognise your project as a Symfony project along with all the added benefits, but also with the ease of setting up new Symfony projects with one command from the CLI.
If you really want to stick to the Net-beans way, simply allow Net-beans to install it, however it chooses. Once it's installed change the version number within the composer.json file. The biggest issue you'll have for this is you'll have to check all your version numbers are compatible.

Symfony downgrade from 3.2 to 2.8 lts

I have started with symfony 3.2 project, then changed version in composer to 2.8 (which is long term support).
Problem is that folders structure still remains 3.2 project. Is there any way to change (not manually) folders structure to 2.8?
Of course you can downgrade. You might choose the old Symfony2 directory structure (deprecated) or keeping the current Symfony3 structure.
In either ways, please take a look at How to Override Symfony's Directory Structure.
Using the Symfony3 directory structure
If you choose to use the Symfony3 structure, it's easy as following up this article about upgrading from Symfony2 to Symfony3's directory structure.
Using the Symfony2 directory structure
First you'll have to rename and move some files (like var/cache/, var/logs/, etc.). Afterwards you'll have to change the autoloading file in app/autoload.php (formerly var/autoload.php which you must move too).
Basically it's the same in reverse order like upgrading from Symfony2 to Symfony3 (mentioned above).
Please be aware that Symfony 3.4 (next LTS) will be released in November 2017, so in my opinion it's not worth to downgrade, and then re-upgrade. Upgrading from 3.2 to 3.4 will be small and fast, Upgrading from 2.8 to 3.4 could be much more to do ...

Update project based on Symfony 2.0 to Symfony 2.2

I am trying to update my project written in Symfony 2.0 into Symfony 2.2.
Moving source codes into 2.2 project ended with config.yml and security.yml incompatibiliy.
Is there way how to properly migrate Symfony 2.0 project into Symfony 2.2?
It better to wait until Symfony 2.3 before migrating. It will be released somewhere in May. It's the first LTS (Long Time Support) release, meaning that it's maintained for three years. So: You don't have to worry about BC breaks for 3 years!
For the migrating of Symfony 2.0 to 2.3: There is nothing you can do. Read the UPGRADE-*.md files (which are stored in the root of the symfony/symfony package) and fix anything that is in their in your code. Every BC break that's important for normal users will be put in those UPGRADE files.
If you can't solve it after the fixing everything in the UPGRADE files, you should take a look at the CHANGELOG.md files in the root of the package (e.g. the symfony/security package). Try to find something that is changed and cause your code to break.
Finally, if you don't get your script working, there are a lot of active Symfony2 users who are waiting to help you. Take a look at the community page and find your place to ask questions.

Categories