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.
Related
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.
I got this error as i validate my composer.json file:
[Composer\Json\JsonValidationException]
"./composer.json" does not match the expected JSON schema:
- name : Does not match the regex pattern ^[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9](([_.]?|-{0,2})[a-z0-9]+)*$
The name Property looks like this:
"name":"lukas735/united-in-faith",
I also tried out the following alternations:
"lukas735/united-in-faith",
"lukas/united-in-faith",
"lukas735/united.in.faith",
"lukas/united.in.faith",
"lukas735/united_in_faith",
"lukas/united_in_faith",
"lukas/uif",
"lukas735/uif",
None of this worked... The regex proofer said the forward slash is placed wrong... But its composer intern so i can't change anything on that. And anyway. My strings also not got matched if i corrected that in regex proofer.
Is there anyway to let match my united-in-faith String... The name before was just an account name because a video said this vendor-name can be choosed yourself... But video was from 2016. I found no hints in internet where to find the vendor-name. So i choosed it myself.
I saw some videos and topics about this naming convention, but they all not seemed to giving an answer which solved it.
What did I wrong?
Has anybody a solution for this error?
Here is my Composer.json File:
{
"name":"lukas735/united-in-faith",
"description":"description",
"keywords": [
"united-in-faith",
"united in faith",
"united_in_faith",
"dating"
],
"homepage": "https://...",
"license": "MIT",
"authors": [
{
"name": "...",
"email": "....",
"homepage": "...",
"role": "Developer"
}
],
"repositories":[
{
"type": "package",
"package": {
"name": "lukas735/united-in-faith",
"version": "1.0.0",
"source": {
"url": "https://github.com/...",
"type": "git",
"reference": "master"
}
}
}
],
"require": {
"components/jqueryui": "^1.12",
"united-in-faith": "dev-master"
},
"autoload": {
"psr-4": {
"lukas735\\": "sites/classes"
}
},
"recommend":{
"ext-zip":"*"
},
"bin":["bin"],
"config":{
"vendor-dir":"vendor"
},
"scripts": {
"test": "phpspec run",
"format": "phpcbf --standard=psr2 src/"
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
}
}
use command 'composer init' to make a new composer.json file, use old for reference
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 .
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 !
I'm trying to use the PHP-SDK and I just can't get it to work. I'm not familiar with the use and namespace statements in PHP and I'm trying to understand it.
{
"repositories": [
{
"type": "package",
"package": {
"name": "payone/php-sdk",
"version": "1.0.0",
"dist": {
"url": "http://github.com/PAYONE/PHP-SDK/archive/master.zip",
"type": "zip"
},
"autoload": {
"psr-0": { "Payone_": "php/" }
}
}
}
],
"require": {
"payone/php-sdk": "1.0.*"
}
}
As far as I understand this tries to load the Autoload.php in my payone/php-sdk/php folder with the class prefix Payone_. This seems fine to me but I can't use $builder = new Payone_Builder(); in my controller now. What am I doing wrong?
You need to add the use statement to your controller.
use Payone_Builder;
as per 2015/03 new zip url
{
"repositories": [
{
"type": "package",
"package": {
"name": "payone/php-sdk",
"version": "1.0.0",
"dist": {
"url": "http://www.payone.de/uploads/media/php-sdk.zip",
"type": "zip"
},
"autoload": {
"psr-0": {"Payone_": "php/"}
}
}
}
]
}