have composer install wordpress and symfony2 - wordpress

Using Composer, i am trying to get symfony2 installed in a directory, and wordpress in another.
Using info found here http://roots.io/using-composer-with-wordpress/ i figured i could just edit my sf2 composer.json and add the required info, but no luck.
Is this possible, or should i create another composer.json file in the subdirectory ?
For reference, here is the (simplified) json:
{
"repositories": [
{
"type": "package",
"package": {
"name": "wordpress",
"type": "webroot",
"version": "3.8",
"dist": {
"type": "zip",
"url": "https://github.com/WordPress/WordPress/archive/3.8.zip"
},
"require" : {
"fancyguy/webroot-installer": "1.0.0"
}
}
}
],
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-0": { "": "src/" }
},
"require": {
"php": ">=5.3.3",
"symfony/symfony": "~2.4",
"wordpress": "3.8",
"fancyguy/webroot-installer": "1.0.0"
},
"config": {
"bin-dir": "bin"
},
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
},
"branch-alias": {
"dev-master": "2.4-dev"
},
"webroot-dir": "wp",
"webroot-package": "wordpress"
}
}
The error i get is:
symfony/framework-standard-edition 2.4.x-dev requires wordpress 3.8 -> no matching package found
Thanks for taking the time to read this !

Related

Wordpress bedrock plugins installed via composer are going into vendor instead of the plugins folder

This has just randomly started happening and i've never seen this so i'm not sure how to fix it. I came to reinstall all the plugins for a bedrock install from wpackagist and instead of going into web/app/plugins they are all installing in the vendor folder. They weren't doing this last time i installed them, here is composer.json, nothing has changed so i don't know what is going on:
{
"name": "roots/bedrock",
"type": "project",
"license": "MIT",
"description": "WordPress boilerplate with modern development tools, easier configuration, and an improved folder structure",
"homepage": "https://roots.io/bedrock/",
"authors": [
{
"name": "Scott Walkinshaw",
"email": "scott.walkinshaw#gmail.com",
"homepage": "https://github.com/swalkinshaw"
},
{
"name": "Ben Word",
"email": "ben#benword.com",
"homepage": "https://github.com/retlehs"
}
],
"keywords": [
"bedrock", "composer", "roots", "wordpress", "wp", "wp-config"
],
"support": {
"issues": "https://github.com/roots/bedrock/issues",
"forum": "https://discourse.roots.io/category/bedrock"
},
"repositories": [
{
"type": "composer",
"url": "https://wpackagist.org",
"only": ["wpackagist-plugin/*", "wpackagist-theme/*"]
},
{
"type": "vcs",
"url": "git#github.com:clickds/save-share-cart.git"
},
{
"type": "vcs",
"url" : "git#github.com:clickds/woocommerce-additional-variation-images.git"
}
],
"require": {
"php": ">=7.1",
"composer/installers": "^1.11",
"vlucas/phpdotenv": "^5.3",
"oscarotero/env": "^2.1",
"roots/bedrock-autoloader": "^1.0",
"roots/bedrock-disallow-indexing": "^2.0",
"roots/wordpress": "5.8",
"roots/wp-config": "1.0.0",
"roots/wp-password-bcrypt": "1.0.0",
"wpackagist-plugin/woocommerce": "^5.7",
"wpackagist-plugin/disable-gutenberg": "^2.5",
"wpackagist-plugin/custom-field-builder": "^1.2",
"clickds/save-share-cart" : "^1.0.4",
"wpackagist-plugin/woocommerce-gateway-stripe": "^5.8",
"wpackagist-plugin/all-in-one-wp-security-and-firewall": "^4.4",
"wpackagist-plugin/w3-total-cache": "^2.1",
"wpackagist-plugin/woocommerce-gateway-paypal-express-checkout": "^2.1",
"wpackagist-plugin/simple-taxonomy-ordering": "^2.3",
"wpackagist-plugin/wp-mail-smtp": "^3.2",
"glenelkins84/woocommerce-additional-variation-images" : "^1.9.2",
"wpackagist-plugin/import-xml-feed": "^2.1",
"wpackagist-plugin/woo-variation-swatches": "^1.1",
"wpackagist-plugin/woo-custom-related-products": "^1.3",
"wpackagist-plugin/purchase-orders-for-woocommerce": "^1.8"
},
"require-dev": {
"squizlabs/php_codesniffer": "^3.6.0",
"roave/security-advisories": "dev-master"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"allow-plugins": {
"composer/installers": false,
"roots/wordpress-core-installer": true
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"extra": {
"installer-paths": {
"web/app/mu-plugins/{$name}/": ["type:wordpress-muplugin"],
"web/app/plugins/{$name}/": ["type:wordpress-plugin"],
"web/app/themes/{$name}/": ["type:wordpress-theme"]
},
"wordpress-install-dir": "web/wp"
},
"scripts": {
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
],
"test": [
"phpcs"
]
}
}
It seems "WordPress boilerplate" works separately from WordPress core.
Generally, using composer, the installed packages are stored in the vendor folder and can be called by requiring autoload.php file in your project.

Ignore packagist.org and specify path for one bundle

I modified a symfony 4 bundle to fix some bug. I now want to deploy my project through https://deployer.org/.
So I added this bundle not ignored in the .gitignore so that the folder of the bundle with my modifications is available on my github repo.
When executing the "deploy" command of deployer, it executes the command "/composer.phar install --verbose --prefer -dist --no-progress --no-interaction --no-dev --optimize-autoloader --no-suggest" so that the folder of my bundle edit is overwritten by the original bundle folder from https://packagist.org/.
I would like to modify my composer.json to define the path of my modified bundle and that it is not overwritten.
Here is what I tried in the composer.json of my main project:
{
"type": "my-project",
"license": "proprietary",
"repositories": [
{
"type": "path",
"url": "/vendor/my/modifiedBundle",
"packagist.org": false,
}
],
"require": {
......
"my/modifiedBundle": "0.6.1",
......
},
"require-dev": {
.....
},
"config": {
"preferred-install": {
"my/modifiedBundle": "source",
"*": "dist"
},
"sort-packages": true
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"App\\Tests\\": "tests/"
}
},
"replace": {
....
},
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
},
"post-install-cmd": [
"#auto-scripts"
],
"post-update-cmd": [
"#auto-scripts"
]
},
"conflict": {
"symfony/symfony": "*"
},
"extra": {
"symfony": {
"allow-contrib": true,
"require": "4.3.*"
}
}
}
Here is the composer.json of my modified bundle:
{
"name": "my/modifiedBundle",
"type": "symfony-bundle",
"license": "MIT",
"require": {
...
},
"require-dev": {
...
},
"config": {
"sort-packages": true
},
"autoload": {
"psr-4": {
"my\\modifiedBundle\\": ""
}
},
"autoload-dev": {
"psr-4": {
"my\\modifiedBundle\\Tests\\": "tests/"
}
}
}
But after my modifications, the modified bundle is still overwritten by the original bundle, do you have any idea?
#Skros2 solved his problem on:
Fork the bundle to its own repository
Edit the fork
Refer his fork on his composer.jsonproject
how to refer a fork.
{
"repositories": [
{
"type": "git",
"url": "https://github.com/foobar/intermediate.git"
},
{
"type": "pear",
"url": "http://pear.foobar.repo",
"vendor-alias": "foobar"
}
],
"require": {
"foobar/TopLevelPackage1": "*",
"foobar/TopLevelPackage2": "*"
}
}

Composer install git repo into custom path (Wordpress theme)

I have a custom Wordpress theme hosted on Bitbucket that I'd like installed into the /themes directory in Wordpress when I run composer install.
I've played around with different repo 'types' e.g. vcs, package etc and I get errors for everything I've tried so far.
Here's a sample of my (not working) composer.json file:
{
"authors": [
{
"name": "Joe Bloggs",
"homepage": "http://www.example.com/"
}
],
"keywords": [
"wordpress", "composer", "wp"
],
"config": {
"secure-http": false
},
"repositories": [
{
"type": "composer",
"url": "http://wpackagist.org"
},
{
"type": "package",
"package": {
"name": "wordpress/wordpress",
"version": "4.5.3",
"type": "webroot",
"dist": {
"type": "zip",
"url": "https://wordpress.org/wordpress-4.5.3.zip"
},
"require" : {
"fancyguy/webroot-installer": "1.1.0"
}
}
},
{
"type": "vcs",
"url": "https://bitbucket.org/gurtfrobe/plunderscores.git"
}
],
"require": {
"php": ">=5.3.2",
"wordpress/wordpress": "4.5.3",
"fancyguy/webroot-installer": "1.1.0",
"composer/installers": "v1.0.12",
"gurtfrobe/plunderscores": "1.0.1"
},
"extra": {
"installer-paths": {
"wp/wp-content/plugins/{$name}/": ["type:wordpress-plugin"],
"wp/wp-content/mu-plugins/{$name}/": ["type:wordpress-muplugin"],
"wp/wp-content/themes/{$name}/": ["type:wordpress-theme"]
},
"webroot-dir": "wp",
"webroot-package": "wordpress/wordpress"
}
}
I've also tried the following with no luck:
{
"type": "package",
"package": {
"name": "gurtfrobe/plunderscores.git",
"version": "1.0.1",
"type": "wordpress-theme",
"source": {
"url": "https://bitbucket.org/gurtfrobe/plunderscores.git",
"type": "vcs",
"reference": "master"
}
}
},
Is there a way of achieving this without submitting my theme to wpackagist?
I solved it with this article.
Remember to push the latest version tags after you've updated your composer.json file. Otherwise Composer will still try and download a previous version.

Symfony2 : Replace parameters.php for PAAS (Heroku)

I use Symfony2 App. I would like to replace parameters.php auto-generated by parameters.heroku.php to have environment variables. This file must be replaced before Symfony2 actions (dumping assets, database update, etc).
What are best practices please ?
I tried to put this action in the composer.json, but this action will launch at each update composing, even outside of Heroku.
My actual composer.json :
{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-0": {
"": "src/"
}
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/Evolunium/IvoryCKEditorBundle"
}
],
"require": {
"php": ">=5.3.3",
"symfony/symfony": "~2.7",
...
},
"scripts": {
"post-install-cmd": [
"./composer_script.sh",
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
],
"post-update-cmd": [
"cp parameters.heroku.php.dist app/config/parameters.php", // Correct ?
"./composer_script.sh",
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
],
"compile": [
"rm web/app_dev.php",
"app/console assetic:dump"
]
},
"config": {
"bin-dir": "bin",
"component-dir": "web/components",
"component-baseurl": "/components"
},
"minimum-stability": "stable",
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
},
"branch-alias": {
"dev-master": "2.3-dev"
},
"config": {
"bin-dir": "bin",
"component-dir": "web/components",
"component-baseurl": "/components"
},
"require-dev": {
"johnkary/phpunit-speedtrap": "~1.0#dev"
}
}
}
Regards,
Johnny

composer set a git repository as type component

I'm trying to install some external JS libraries located in Github in a SF2 project with composer.json.
composer.json:
{
"name": "myproject",
"license": "my project",
"type": "project",
"description": "my project",
"autoload": {
"psr-0": { "": "src/" }
},
"repositories": {
"medium-editor" : {
"type": "package",
"package": {
"name": "daviferreira/medium-editor",
"type": "component",
"version": "master",
"source": {
"url": "git://github.com/daviferreira/medium-editor.git",
"type": "git",
"reference": "master"
},
"extra": {
"component": {
"scripts": [
"dist/js/medium-editor.min.js"
],
"styles": [
"dist/css/medium-editor.min.css",
"dist/css/themes/*.min.css"
]
}
},
"require": {
"robloach/component-installer": "*"
}
}
},
"classList" : {
"type": "package",
"package": {
"name": "eligrey/classList.js",
"type": "component",
"version": "master",
"source": {
"url": "git://github.com/eligrey/classList.js.git",
"type": "git",
"reference": "master"
},
"extra": {
"component": {
"scripts": [
"classList.min.js"
]
}
},
"require": {
"robloach/component-installer": "*"
}
}
}
},
"require": {
...
"daviferreira/medium-editor" : "dev-master",
"eligrey/classList.js" : "dev-master"
},
"require-dev": {
"phpunit/phpunit": "3.7.*"
},
"scripts": {
"post-install-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
],
"post-update-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
]
},
"config": {
"bin-dir": "bin",
"component-dir": "web/components"
},
"minimum-stability": "stable",
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web",
"symfony-assets-install": "symlink",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
},
"branch-alias": {
"dev-master": "2.3-dev"
}
}
}
The libraries are downloaded but...
I'm expecting that composer will create, with the "robloach/component-installer" dependency, a copy of the files specified in "extra" of the "component" type package to the "web/component" directory, but it doesn't.
What's wrong with my config? Thanks!
After reading more carefully the robloach plugin documentation, I've tried again and finally found a solution. The problem was that I probably had made a lot of "composer update" with different configs and was obliged to remove / reinstall the packages to make it work! So the original config post in the question is the good one...
I put it again to be sure!
"medium-editor" : {
"type": "package",
"package": {
"require": {
"robloach/component-installer": "*"
},
"name": "daviferreira/medium-editor",
"type": "component",
"version": "master",
"source": {
"url": "git://github.com/daviferreira/medium-editor.git",
"type": "git",
"reference": "master"
},
"extra": {
"component": {
"scripts": [
"dist/js/medium-editor.min.js"
],
"styles": [
"dist/css/medium-editor.min.css",
"dist/css/themes/*.min.css"
]
}
}
}
},
And for sure, don't forget to add the Robloach component in the "require" libraries:
"robloach/component-installer": "dev-master",
I would suggest to use bower for fetching frontend libraries. Composer was created for managing php libs dependencies. It is importand to separate this layers because it's the easiest solution to implement.
Try PHP Composer Asset Manager package with composer if the problem persist i think you should execute the command manualy:
app/console assets:install .

Resources