Upgrade symfony from skeleton to website-skeleton - symfony

I've just been experimenting with Symfony 4, and started out with a console app, so ran:
composer create-project symfony/skeleton my-project
I now realise that was a mistake, and instead want the website skeleton
composer create-project symfony/website-skeleton my-project
What's the simplest way to upgrade my existing project to have everything that comes in website-skeleton?

If you've just been experimenting, the simplest way would be to create a new project with symfony/website-skeleton and eventually integrate into it the code you developped and want to keep.
symfony/website-skeleton is not an upgrade, it just installs more dependencies by default for users who don't want to install them manually.
So if you really want to keep the existing project, you could add the missing dependencies yourself with composer.
You can find a list of the dependencies here.

Related

How to run symfony cli command with --webapp using local composer.phar?

I run different versions of Symfony and PHP on my Mac for various apps I have to work on (sorry that our clients are so slow to get to upgrade), and I'm trying to install the LTS version of Symfony through the CLI documentation recommendations, but I'm trying to get it to use a composer.phar in the folder I run the command in... it keeps defaulting to the globally-installed one.
Sure I could just go change composer's execution path or upgrade/downgrade it temporarily whenever I want to run the cli for x version of PHP, but that's gonna drive me crazy and I'd rather see how to tell it to run a certain composer.phar file. I'm not seeing in the documentation how to do this to get the benefits of the --webapp option.
The documentation is weird on it anyway; I can't tell if running composer directly (as composer.phar) will give me the benefits of the --webapp option using the symfony command (because the composer commands are identical for 'traditional web application' and 'console application or API'):
https://symfony.com/doc/5.4/setup.html#creating-symfony-applications
# run this if you are building a traditional web application
$ symfony new my_project_directory --version=5.4 --webapp
# run this if you are building a microservice, console application or API
$ symfony new my_project_directory --version=5.4
# run this if you are building a traditional web application
$ composer create-project symfony/skeleton:"^5.4" my_project_directory
$ cd my_project_directory
$ composer require webapp
# run this if you are building a microservice, console application or API
$ composer create-project symfony/skeleton:"^5.4" my_project_directory
When I run the install through composer directly, I can't tell if I'm getting the benefits of the symfony command --webapp option... and I'm not seeing an option for the symfony command to specify to use the folder's composer.phar.
I had to cheat a little bit: I installed the latest composer using the instructions here to a composer.phar file:
https://getcomposer.org/download/
I then created a console alias like php composer.phar, ran the Symfony create composer command with that alias, which created the symfony-5 folder no problem, then I copied the composer.phar file to the new folder and run the alias for any other composer commands, like with require webapp, which is working! Kind of nice to freeze a version of composer for any similar repos.
Maybe not the best answer, but it's working.
Also I discovered that I could just run composer self-update to get the latest version, which worked, then composer self-update [whatever version number] to get back to one I need that works with other repos (since certain version ranges just do not work with certain version ranges of PHP). Annoying, but functional.
Ultimately I think moving forward, it's best to make a copy of composer.phar at a compatible version range for your older PHP apps, depending on their versions, and use those in an alias, rather than totally rely on a global composer version, which has proven not completely workable for my work.

How can I upgrade Webpack Encore bundle?

I have a Symfony 4.4 project and I need to upgrade from symfony/webpack-encore-pack to symfony/webpack-encore-bundle. I want to do it in the best way, so can you tell me what's the best practice to do this operation (to take care of possibile dependencies and so on)?
Temporarily rename your existing webpack.config.js to webpack.config.bak.js to allow Symfony Flex to copy a fresh config there.
Replace symfony/webpack-encore-pack dependency with symfony/webpack-encore-bundle in your composer.json
Run composer update - it should replace the old package with the new one and Symfony Flex will copy default configuration from the recipe: https://github.com/symfony/recipes/tree/master/symfony/webpack-encore-bundle/1.9
Upgrade your yarn/npm dependencies using yarn upgrade #symfony/webpack-encore or npm upgrade #symfony/webpack-encore.
Update your new webpack.config.js with JS/CSS entries from the back up file. Please note that syntax and option names might have changed - check CHANGELOG.md.
Run npm run dev to see if your assets are still building properly.

How to create production stability drupal 8 project using composer?

I've been getting to drupal and recently found out about composer. I use the following command to create a dev drupal instance:
composer create-project drupal-composer/drupal-project:~8.x-dev <folder-name> --stability dev --no-interaction
I was wondering what the package name is for the stable release of drupal.
Thank you.
You shouldn't need to change anything about your core build, both development and production will be running the current build of drupal/core. But modules like Devel or Stage File Proxy can be added to the require-dev section in your composer.json and installed while doing development and kept out of the build on production.
Hopefully this link will help: https://www.drupal.org/docs/8/update/update-core-via-composer#update-drupal-8-core
The very last part about Production environments says to run composer install --no-dev to remove any dev dependencies from the build.

Deploy full Symfony2 app with composer

Is there a way to setup a composer.json file in order to deploy a full Symfony 2.3 app?
Suppose I have the app in the git repo https://myrepo#bitbucket.org/myrepo/sfwebapp.git
As far as I know, composer is dependency manager, not deployment manager. Sure, you could:
Pull Git repo
Run composer --install (this is basically the essential step)
Warm up cache
Symlink resources
Install assets
...
PROFIT
BUT, You would need to manually:
Check/perform initial directory structure setup
Keep track of old deployments
...
So, bottom line, you could achieve it but it would be like reinventing the wheel.

How can I install the Buzz bundle on Symfony 2.2.0?

I want to install the Buzz bundle. On GitHub, the installation instructions suggest the .bin/vendors install method. However, that's not supported in Symfony 2.2.0.
Is there another way I could install the bundle? I've been trying to install it using Composer, but without any luck.
Try adding in composer.json under require key:
"sensio/buzz-bundle": "dev-master"
Then follow the instructions from step3 onward
You'll also need to run composer.phar update after that.
And for future reference, lookup the package you need on packagist.org. You'll find there what you need to put in composer.json

Resources