ZendService\WindowsAzure with zf2 - php

I'm trying to install zendservice-windowsazure using composer. My composer.json looks like this:
{
"repositories": [{
"type": "pear",
"url": "http://pear.php.net"
},
{
"type": "composer",
"url": "https://packages.zendframework.com/"
}],
"require": {
"microsoft/windowsazure": "*",
"zendframework/zendservice-windowsazure": "2.*"
},
"minimum-stability": "dev"
}
According to the docs here:
http://framework.zend.com/manual/2.1/en/modules/zendservice.windows-azure.html
I can then create a new storage client like so:
$storageClient = new ZendService\WindowsAzure\Storage\Blob();
However, the source that composer installs is structured differently and appears to be a completely different version to the classes referenced in the documentation. For example, the above call, according to the source code that composer has installed, is actually:
$storageClient = new ZendService\WindowsAzure\Storage\Blob\Blob();
But then when listing blobs, the installed zendservice-windowsazure library calls:
Zend\Http\Client->request()
which is no longer a valid method in the Client class.
So it looks like either:
a) The wrong version of zendservice-windowsazure is being installed
b) The Zend documentation is incorrect
I'm inclined to think it's the first option, due to the invalid reference to
Zend\Http\Client->request()
If that's the case, how can I get the latest version of the module? Even the github repo for the module is the same version as that installed by composer, and therefore doesn't work as specified in the documentation.
https://github.com/zendframework/ZendService_WindowsAzure

You can use old Windows Azure SDK for PHP 4.1.0 http://phpazure.codeplex.com/releases/view/78020. It works fine.

Related

composer packages.json autoload definition

I use composer libraries in my private project to manage common logic and I used to always install them with a "vcs" repository definition like this:
"require": {
"private/package": "dev-develop",
},
"repositories": {
{
"type": "vcs",
"url": "http://localhost/git/private-package.git"
}
}
... which used to work like a charm but was tedious for project where I would use many libraries at once.
So I decided to write my own "composer" type repository that dynamically generates a "packages.json" with all my libraries that looks something like this:
"packages" {
"private/package": {
"dev-develop": {
"name": "private/package",
"version": "dev-develop",
"source": {
"type": "git",
"url": "http://localhost/git/private-package.git",
"reference": "origin/develop"
}
}
}
}
The installation works fine but it does not generate the autoloader properly anymore. The installation does not read the "composer.json" file of the actual vcs repository anymore.
The autoloader only works properly if I include the autoloader definition in the "packages.json" file.
I want composer to use the "packages.json" definition, but still read the autoloader definition from the actual package. My question is if that is possible.
If the autoloader definition changes with a newer version of the library, the definition in "packages.json" will not work with an older version anymore so I am thinking there should be another way to solve this problem.

Composer: How to override a requirement globally for composer.json?

TL;DR:
My Project requires library A, A requires B1.
B1 is broken but there is a fork B2.
I want to achieve that composer will install B2 instead of B1 even if A requires B1 and not B2.
How to do that?
More in detail:
In a symfony project we require the following library:
"require": {
"emanueleminotto/twig-cache-bundle": "1.0.2",
}
This library requires itself another library that is currently broken:
"require": {
"asm89/twig-cache-extension": "^1.3"
},
For the broken library exists already a pull request for over 4 month but the maintainer refuses to merge it.
My question is, if it would be possible to overwrite the dependencies also for sub-dependencies, that always the patched fork would be used instead of the original one?
For the asm89/twig-cache-extension exists the following fork with fixes: https://github.com/blackandred/twig-cache-extension
I tried to add this fork to my composer.json and registered the fork explicitly under "repositories":
"repositories": [
{
"type": "git",
"url": "https://github.com/blackandred/twig-cache-extension"
}
],
and added the dependency also in my composer-json with a changed version to "dev-master":
"require": {
"asm89/twig-cache-extension": "dev-master",
"emanueleminotto/twig-cache-bundle": "1.0.2",
}
But since the emanueleminotto/twig-cache-bundle still requires the original library, composer ignores the fork and installs the original.
Anything i can do here?
I believe the docs have a good example for this scenario.
Basically you need to define an alias in your composer.json as following:
"require": {
"asm89/twig-cache-extension": "dev-master as 1.3",
"emanueleminotto/twig-cache-bundle": "1.0.2",
}
Added by the questioner:
One step was still missing: "composer update asm89/twig-cache-extension"
Add the replace section into composer.json of your fork:
{
"replace": {
"asm89/twig-cache-extension": "self.version"
}
}

TYPO3 - Loading external libraries in my Extbase extension with composer works in development context but not in production

I'm using TYPO3 6.2.26, I added to my extension an external library (sinergi/browser-detector) using composer. We have two servers one for development and another for production. The problem appear in the production context, but in development work it excellent.
I have the next structure on both servers (git subversion):
myext/Resources/Private/composer.json
myext/Resources/Private/Libraries/autoload.php (generate by composer)
myext/Resources/Private/Libraries/sinergi/...
myext/Resources/Private/Libraries/composer/... (generate by composer)
myext/ext_autoload.php
I load the composer loader in the ext_autoload.php:
require __DIR__ . '/Resources/Private/Libraries/autoload.php';
My composer.json look like this:
{
"name": "vendor/vendor",
"description": "My description",
"type": "library",
"require-dev": {
"sinergi/browser-detector": "^6.1"
},
"config": {
"vendor-dir": "Libraries"
},
"authors": [
{
"name": "xxx",
"email": "xxx"
}
]
}
With this configurations it works without problems in the development environment. In production occurs a strange situation, when I delete the cache it works only one time, at the second time the web server returns a 500 Error:
PHP Fatal Error: class Sinergi\\BrowserDetector\\...not found...
I tried some solution which I founded in Internet like:
Adding to my composer.json:
"autoload":
"prs-4": {
"Sinergi\BrowserDetector\" : "Libraries/sinergi/browser-detector/src/"
}
Dumping the autoload
composer dump-autoload
Disabling opcache
Deleting composer.lock and new install
But, the problem is still there only in production. I remove too the content of the typo3temp directory, and then it works one time, but at the second 500 Error. Do anybody know what can I make?
I don't know how your files end up on production but you should use
"require": {
"sinergi/browser-detector": "^6.1"
},
instead of require-dev, otherwise, it is just for dev.

Laravel 4 custom package not appearing in autoload_namespace.php

Laravel 4 custom package not appearing in autoload_namespace.php
I have tried to create a custom package by creating a workbench package in one of my laravel apps, committing it to github and then installing it in a different package. My problem is that the namespace map is not being added to autoload_namespace.php and the knock on effect of this is that the line
Markfee\Responder\ResponderServiceProvider in my providers array causes the following error when i run:
php artisan dump-autoload
Error Output:
PHP Fatal error: Class 'Markfee\Responder\ResponderServiceProvider' not found in /media/sf_wwwshare/feenance/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php on line 157
The package can be found at:
https://github.com/markfee/responder.git
I include the package with the following entries in my composer.json file
"repositories": {
"responder": {
"type": "package",
"package": {
"name": "markfee/responder",
"description": "Simple responder class for responding with json from api",
"version": "0.1.0",
"source": {
"type": "git",
"url": "https://github.com/markfee/responder.git",
"reference": "a7a24c82479fc01ec0c06833690bfd2eeee9e47d"
}
}
}
},
"require": {
"laravel/framework": "4.2.*",
"markfee/responder": "0.1.*"
},
If anyone can shed any light I'd be very greatful. Please ask if you need any further details.
You did the complicated way by providing a package definition for that repository. If you do that, this package is a complete replacement for any composer.json in that repository, and this should only be used in case there is none.
You didn't add the autoloading definition into that package, so it is correctly missing in your autoloading.
Suggestion: Avoid using type:package in your own composer.json file. Simply use type:vcs if the repository already has a composer.json.
If you want to use the master branch just like a tagged version, you can add an alias in your require statement: "markfee/responder": "dev-master as 0.1.0". You could also clone that repo and tag the commit you want in your own local copy, and reference your own repo instead. Or try to convince the maintainer to tag a version and add his repo to packagist.org.
with help from Sven I got this working, the exact changes I made were to replace the original entry in my composer.json with the following. I didn't use an alias as I just want to include the master branch at the moment. Versioning and adding to packagist are my next task:
"repositories": {
"responder": {
"type": "vcs",
"url": "https://github.com/markfee/responder.git"
}
},
"require": {
"laravel/framework": "4.2.*",
"markfee/responder": "dev-master"
},

How do I define an explicit SVN revision for a Composer repository?

I'm trying to include google-api-php-client library to my project using Composer. Simpliest way is to get library from VCS trunk branch, but I think it's not the best idea in my case. Much better will be point to some stable library state (tag or revision). Whereas there's no tags available, get a particular svn revision is the only option. But I have no idea how to do this.
I tried different package configs with no success, something like this:
{
"repositories":[
{
"type":"package",
"package":{
"name":"project/google-api-php-client",
"version":"0.2.1",
"source":{
"type":"svn",
"url":"http://google-api-php-client.googlecode.com/svn",
"reference":"trunk/?r=515"
}
}
}
]
}
Whether it possible at all to checkout svn revision with composer? Thanks in advance.
Using a package repository when you are defining the version you can specify a revision in the reference. An example from my wordpress composer.json
{
"repositories": [
"type": "package",
"package": {
"name": "wordpress-plugin/wp-minify",
"type": "wordpress-plugin",
"version": "1.2",
"source": {
"type": "svn",
"url": "http://plugins.svn.wordpress.org/wp-minify",
"reference": "trunk#691320"
},
"require": {
"composer/installers": "~1.0"
}
}
]
}
This installs the plugin from the trunk with an explicit revision of 691320.
The version can be set in the require part (that you don't show).
The only SVN options available are:
{
"repositories": [
{
"type": "vcs",
"url": "http://svn.example.org/projectA/",
"trunk-path": "Trunk",
"branches-path": "Branches",
"tags-path": "Tags"
}
]
}
Look's like you want to use a package, but you could also just define this repository and require the appropriate version (can you tag? It's easier).
You could also try to put the revision insive the version parameter but I don't think that will work.
Also, the documentation state that about the "trunk" path:
Since Subversion has no native concept of branches and tags, Composer
assumes by default that code is located in $url/trunk, $url/branches
and $url/tags. If your repository has a different layout you can
change those values.

Categories