I have a own TYPO3 extension hosted on bitbucket. Getting this via composer works (see here for input). The extension is downloaded into my vendor folder. Being there i cannot install the extension via extension-manager.
How can I getting my ext into typo3conf/ext (ensuring autoloading will work)?
The extensions coming via
{
"type": "composer",
"url": "http://composer.typo3.org/"
}
are going to (as expected):
web/typo3config/ext
here is my project composer.json:
{
"repositories": [
{
"type": "composer",
"url": "http://composer.typo3.org/"
},
{
"type": "package",
"package": {
"name": "metaxos/exaibbrplus",
"version": "dev-2016",
"source": {
"url": "https://metaxos#bitbucket.org/metaxos/exaibbrplus.git",
"type": "git",
"reference": "release/2016"
}
}
}
],
"name": "Metaxos/ibbrating2016",
"require": {
"typo3/cms": "7.6.2",
"bk2k/bootstrap-package" : "dev-master",
"typo3-ter/compatibility6" : "7.6.0",
"typo3-ter/extension-builder" : "7.6.0",
"metaxos/exaibbrplus": "dev-2016"
},
"extra": {
"typo3/cms": {
"cms-package-dir": "{$vendor-dir}/typo3/cms",
"web-dir": "web"
}
}
}
here is my extension composer.json:
{
"name": "metaxos/exaibbrplus",
"description": "custom ext for typo3",
"type": "typo3-cms-extension",
"version": "0.0.1",
"require": {
"typo3/cms-core": ">=7.6.0,<8.0"
},
"replace": {
"extkey": "self.version",
"typo3-ter/extkey": "self.version"
},
"autoload": {
"psr-4": {
"Metaxos\\Exaibbrplus\\": "Classes/"
}
},
"keywords": ["custom", "ext"],
"homepage": "http://www.blah.ch"
}
For Composer to install the package in web/typo3conf/ext, the package needs to have the type typo3-cms-extension. In your extension's composer.json this type is actually declared, however Composer will not respect it because you explicitly declare the package configuration in your project-level composer.json:
"repositories": [
# ...
{
"type": "package",
"package": {
"name": "metaxos/exaibbrplus",
"version": "dev-2016",
"source": {
"url": "https://metaxos#bitbucket.org/metaxos/exaibbrplus.git",
"type": "git",
"reference": "release/2016"
}
}
}
]
As you're using "type": "package" for your own repository, I suspect that Composer ignores the composer.json from that package. As you already have a Git repository that contains a composer.json, I'd suggest adding the repository using the vcs type instead:
"repositories": [
{
"type": "vcs",
"url": "https://metaxos#bitbucket.org/metaxos/exaibbrplus.git"
}
]
When doing that, Composer should use the composer.json from that repository, recognize the correct package type (typo3-cms-extension) and install the package in the correct directory.
You need to add the type key with the value typo3-cms-extension to the root composer.json. This will place your extension in web/typo3conf/ext instead of vendor/$vendor/$package which in turn will make it available to the cms.
It is important, to know that if you redefine the package in the root composer.json as repository type package, nothing from the extensions' composer.json file will be taken into account and you need to define any concerns about that package in the root composer.json.
So-applying the rules I mentioned above, your root composer.json will look like that:
{
"repositories": [
{
"type": "composer",
"url": "http://composer.typo3.org/"
},
{
"type": "package",
"package": {
"name": "metaxos/exaibbrplus",
"version": "dev-2016",
"type": "typo3-cms-extension",
"source": {
"url": "https://metaxos#bitbucket.org/metaxos/exaibbrplus.git",
"type": "git",
"reference": "release/2016"
},
"autoload": {
"psr-4": {
"Metaxos\\Exaibbrplus\\": "Classes/"
}
},
}
}
],
"name": "Metaxos/ibbrating2016",
"require": {
"typo3/cms": "7.6.2",
"bk2k/bootstrap-package" : "dev-master",
"typo3-ter/compatibility6" : "7.6.0",
"typo3-ter/extension-builder" : "7.6.0",
"metaxos/exaibbrplus": "dev-2016"
},
"extra": {
"typo3/cms": {
"cms-package-dir": "{$vendor-dir}/typo3/cms",
"web-dir": "web"
}
}
}
As mentioned above by #helmbert, you are either left with completely redefining the package or using another repository type. You may want to consider using satis or a URL repository.
try to add
"replace": {
"exaibbrplus": "self.version",
"typo3-ter/exaibbrplus": "self.version"
},
And use only "Metaxos\\Exaibbrplus\\": "Classes/" in the autoloader.
Related
For some reason I'm unable to install Predis package in my project via composer require predis/predis, I have manually downloaded Predis package from https://php-download.com and moved predis folder to the vendor and then updated files inside vendor/composer, it works fine.
However, the problem is when I run composer dump-autoload, this command removes all references of this package from vendor/composer/autoload_psr4.php and autoload_static.php files.
Can someone please help me how can I prevent composer dump-autoload to remove references of this package?
Instead of copying your package to the vendor directory, you can use "repositories" in install a local package:
{
"repositories": [
{
"type": "path",
"url": "../../packages/my-package"
}
],
"require": {
"my/package": "*"
}
}
I fixed it by adding following code in vendor/composer/installed.json , I forgot to add it.
{
"name": "predis/predis",
"version": "v1.1.1",
"version_normalized": "1.1.1.0",
"source": {
"type": "git",
"url": "https://github.com/nrk/predis.git",
"reference": "f0210e38881631afeafb56ab43405a92cafd9fd1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nrk/predis/zipball/f0210e38881631afeafb56ab43405a92cafd9fd1",
"reference": "f0210e38881631afeafb56ab43405a92cafd9fd1",
"shasum": ""
},
"require": {
"php": ">=5.3.9"
},
"require-dev": {
"phpunit/phpunit": "~4.8"
},
"suggest": {
"ext-curl": "Allows access to Webdis when paired with phpiredis",
"ext-phpiredis": "Allows faster serialization and deserialization of the Redis protocol"
},
"time": "2016-06-16T16:22:20+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-4": {
"Predis\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Daniele Alessandri",
"email": "suppakilla#gmail.com",
"homepage": "http://clorophilla.net"
}
],
"description": "Flexible and feature-complete Redis client for PHP and HHVM",
"homepage": "http://github.com/nrk/predis",
"keywords": [
"nosql",
"predis",
"redis"
]
}
I want to add multiple packages that I have forked in composer.
I have used the way that is described in https://getcomposer.org/doc/05-repositories.md#loading-a-package-from-a-vcs-repository but what is described there is for only one package and I want to do it for multiple packages. How should I declare it? I want to add extra repository links.
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/igorw/monolog"
}
],
"require": {
"monolog/monolog": "dev-bugfix"
}
}
I have found the answer.
{
"repositories": [
{ "type": "vcs", "url": "https://github.com/igorw/monolog" },
{ "type": "vcs", "url": "https://github.com/igorw/dialog" }
],
"require": {
"monolog/monolog": "dev-bugfix",
"dialog/dialog": "dev-bugfix"
},
}
i have private repository with some files that are not important now, what i want to create is package to include it to composer.json
{
"name": "pm/multi-curl",
"description": "Package to multicurl",
"version": "master",
"type": "library",
"minimum-stability":"dev",
"require": {
"ext-curl": "^7.1"
},
"repositories": [
{
"type": "package",
"package": {
"name": "pm/multi-curl",
"version": "dev-master",
"source": {
"url": "git#pmgit.pm.com:dk/multicurl.git",
"type": "git",
"reference": "master"
},
"autoload": {
"psr-0" : {
"PM\\MultiCurl" : "src"
}
}
}
}
],
"authors": [
{
"name": "dk",
"email": "dk#example.com"
}
]
}
but when i execute composer require pm/multi-curl composer gives me this message Could not find a version of package pm/multi-curl matching your minimum-stability (stable). Require it with an explicit version constraint allowing its desired stability. i tried to change stability to dev but that didn't help at all. I also tried to do it with composer.json that looks like this:
{
"name": "pm/multi-curl",
"description": "Package to multicurl",
"version": "master",
"type": "library",
"minimum-stability":"dev",
"require": {
"ext-curl": "^7.1"
},
"authors": [
{
"name": "dk",
"email": "dk#example.com"
}
]
}
pmgit.pm.com is gitlab and to inform you when i execute composer search performance-media/multi-curl it returns correct description. What i do wrong.
do you can use the master branch by
composer require pm/multi-curl:dev-master
I have two private repositories, let's call them RepoA and RepoB. RepoA is required by the RepoB and they are both private repos on gitlab with the port 620.
Here are the composer.json in both repo:
Repo A
{
"name": "namespace/repoA",
"description": "My repository A.",
"require": {
"php": ">=5.4"
}
}
Repo B
{
"name": "namespace/repoB",
"description": "My repository B.",
"repositories": [
{
"type": "vcs",
"url": "ssh://git#git.domain.com:620/namespace/repoA.git"
}
],
"require": {
"namespace/repoA": "dev-master"
}
}
Now let's say I have a project (ProjectA), which I want to install RepoB.
Project A
{
"repositories": [
{
"type": "vcs",
"url": "ssh://git#git.domain.com:620/namespace/repoB.git"
}
],
"require": {
"namespace/repoB": "dev-master"
}
}
However, when I run my composer install, I get the following error:
Problem 1
- Installation request for namespace/repoB dev-master -> satisfiable by namespace/repoB[dev-master].
- namespace/repoB dev-master requires namespace/repoA dev-master -> no matching package found.
I understand that it's unable to find the package since it's a private repository, but since it's inside the repositories of the repoB, why is it not fetching it?
I thought it would work if I added the repositories to the Project A:
{
"repositories": [
{
"type": "vcs",
"url": "ssh://git#git.domain.com:620/namespace/repoA.git"
},
{
"type": "vcs",
"url": "ssh://git#git.domain.com:620/namespace/repoB.git"
}
],
"require": {
"namespace/repoB": "dev-master"
}
}
But it still does not work until I add it into my require of my Project Aas well:
{
"repositories": [
{
"type": "vcs",
"url": "ssh://git#git.domain.com:620/namespace/repoA.git"
},
{
"type": "vcs",
"url": "ssh://git#git.domain.com:620/namespace/repoB.git"
}
],
"require": {
"namespace/repoB": "dev-master",
"namespace/repoA": "dev-master"
}
}
Now my question is... How can I make composer install my repoA by specifying only my repoB?
You cannot and here is an explanation: Why can't Composer load repositories recursively?
I use a local repository ("depA") within my projects composer.json:
"repositories": [
{
"type": "package",
"package": {
"name": "marc/depA",
"version": "dev-master",
"source": {
"url": "/Users/Marc/Sites/depA",
"type": "git",
"reference": "develop"
}
}
}
],
"require": {
"marc/depA": "dev-master",
This works like a charm but it won't resolve dependencies from "depA". This means since "depA" requires "depB" (in composer.json of "depA") -> "depB" wont be installed.
Is this even possible with local packages?
Thanks,
Marc
You are defining the package inline so if you do it like this you must redefine all the requires etc inline as well. That's really not the best way to go at it. If it's a git repo and it has a composer.json you'd better use a vcs repository e.g.:
{
"repositories": [
{
"type": "vcs",
"url": "/Users/Marc/Sites/depA"
}
],
"require": {
"marc/depA": "dev-master",
}
}