What does the Value in PHP Composer's key/value Pair Represent? - php

In a PHP composer.json file, the require field contains a number of key/value pairs.
"require": {
"php": ">=5.3.3",
"symfony/console": "~2.3#dev",
"symfony/finder": "2.2.1",
"symfony/yaml": "2.2.1",
"symfony/process": "2.2.1",
"symfony/validator": "2.2.1",
"n98/junit-xml": "dev-master",
"fzaninotto/faker": "1.1.0",
"composer/composer": "dev-master"
},
What, exactly, is the value of each key/value pair used for?
I get that conceptually these are just version numbers. For example, the following
"symfony/finder": "2.2.1"
tells composer that version 2.2.1 of the symfony/finder package is required.
What I'm unclear on is
The syntax allowed for versioning (i.e. what does ~2.3#dev mean)
Why some versions are just text (dev-master)
My assumption is these somehow related to branches or tags in a version control system, or maybe the explicit version defined in a package's composer.json file, but I haven't been able to glean how, exactly, this works.
If anyone knows, or can point me to the right section of the manual where this is explained, I'd appreciate it.

The ~2.3#dev means: "using ~ specifies a minimum version, but allows the last digit specified to go up." and dev means its a dev version, "Available options (in order of stability) are dev, alpha, beta, RC, and stable."
it means its a master branch
All of this i found it here:
http://getcomposer.org/doc/01-basic-usage.md#package-versions
http://getcomposer.org/doc/04-schema.md#minimum-stability
http://getcomposer.org/doc/articles/aliases.md
http://getcomposer.org/doc/04-schema.md#require-dev

Related

How to install google\appengine\api\cloud_storage\CloudStorageTools via composer?

I'm trying to figure out how to let my users upload files in my Google App Engine app. I'm following the instructions here: https://cloud.google.com/appengine/docs/standard/php/googlestorage/user_upload
It starts with:
use google\appengine\api\cloud_storage\CloudStorageTools;
However, that package doesn't exist in any of the vendor directories I've got and I can't figure out what I need to add to my composer.json in order to get this code.
I've got code in other places in my project that will use Google\Cloud\Storage\StorageClient; but that is a different code base and it doesn't contain the CloudStorageTools::createUploadUrl() function which is what I'm trying to get access to.
Here is what my composer.json contains:
{
"require": {
"mailgun/mailgun-php": "^2.6",
"php-http/guzzle6-adapter": "^1.1",
"php-http/message": "^1.6",
"google/cloud-storage": "^1.9",
"google/cloud-debugger": "^0.14.2",
"ext-stackdriver_debugger": "*"
},
"name": "",
"description": ""
}
You need to add google/appengine-php-sdk to your composer.json.
composer require google/appengine-php-sdk

Adding a composer package to Laravel 5

"require": {
"infusionsoft/php-sdk": "^1.2",
"laravel/lumen-framework": "5.1.*",
"vlucas/phpdotenv": "~1.0",
"barryvdh/laravel-debugbar": "^2.2",
"goaop/framework": "^2.0",
"php-http/httplug": "^1.1",
"infusionsoft/old-php-isdk": "*"
},
I'm trying to use the "infusionsoft/old-php-isdk" which is in the packagist composer repository but it's not specific to Laravel. I'm using an order controller and it's code that I picked up from another developer so he references the current (and working) "infusionsoft/php-sdk" as the following
"use infusionsoft\infusionsoft;"
What namespace do I call it if it has no namespace from the package?
Here's the original link to the composer package.
https://packagist.org/packages/infusionsoft/old-php-isdk
Am I missing something? Do I need to assign it a namespace? What and where would I put it?

laravel 5,am I including too much libraries?

I am new to Laravel, and I have started working on Laravel 5.x( the current version on the question date). My app uses bunch of libraries, including Amazon MWS library, a parser and many more, see this image for an idea
these seems to be a lot of folder, and including Laravel Framework folder...
many of these built in options would never by used by me directly and intentionally..Also, say from a library, I would use only one method (tojson method from a lib for example)
Already admitted, I am new to Laravel, and from my native understanding, only parts of libraries are included when called..
So, my basic question is,
When and HOW do you know you are including too much ?
How you people manage this??
thanks...and sorry if my question seems offensive to anyone, I believe its directly relating to programming and will help many others like me too..
There's no problem with including many libraries.
Requiring and installing libraries doesn't create overhead in itself, as that code is executed only when you use it. Also most of the libraries in the vendor directory are Laravel dependencies.
If you look at the framework's composer.json file and you'll see that Laravel already has a lot of dependencies as it uses a lot of Symfony components for the core, Monolog for logging, SwiftMailer for sending emails, and the list goes on:
"require": {
"php": ">=5.5.9",
"ext-mbstring": "*",
"ext-openssl": "*",
"classpreloader/classpreloader": "~3.0",
"doctrine/inflector": "~1.0",
"jeremeamia/superclosure": "~2.2",
"league/flysystem": "~1.0",
"monolog/monolog": "~1.11",
"mtdowling/cron-expression": "~1.0",
"nesbot/carbon": "~1.20",
"paragonie/random_compat": "~1.4",
"psy/psysh": "0.7.*",
"swiftmailer/swiftmailer": "~5.1",
"symfony/console": "2.8.*|3.0.*",
"symfony/debug": "2.8.*|3.0.*",
"symfony/finder": "2.8.*|3.0.*",
"symfony/http-foundation": "2.8.*|3.0.*",
"symfony/http-kernel": "2.8.*|3.0.*",
"symfony/polyfill-php56": "~1.0",
"symfony/process": "2.8.*|3.0.*",
"symfony/routing": "2.8.*|3.0.*",
"symfony/translation": "2.8.*|3.0.*",
"symfony/var-dumper": "2.8.*|3.0.*",
"vlucas/phpdotenv": "~2.2"
},
Just install whatever you need, there's no limit to how many libraries you use as long as your code is written properly.

mb_substr() undefined Facebook canvas - Heroku server

The problem is that when I open the facebook canvas. I get this error. "call to undefined function mb_substr"
The solution that most people suggest is to put "ext-mbstring" as a require. I did that in different way's. This is what I have now:
{
"require" : {
"silex/silex": "~1.3",
"monolog/monolog": "~1.7",
"twig/twig": "^1.19",
"symfony/twig-bridge": "^2.7"
},
"require-dev": {
"heroku/heroku-buildpack-php": "*"
},
"require": {
"ext-mbstring": "*"
}
}
This does not work for me. I have also checked the php info of my heroku server.
This is the output. As you can see the mbstring is set.
What I at last think the problem could be is the php version. Facebook wants a version that's higher than 5.4. I am using version 5.6.15.
So that shouldn't be the problem either.
Anyone knows what I missed?
Since it's a JSON object and require is the property key, I don't think you can just add a second property with the same key. Try to add the dependency to the first require property.
{
"require" : {
"php": ">=5.6.0",
"ext-mbstring": "*",
"silex/silex": "~1.3",
"monolog/monolog": "~1.7",
"twig/twig": "^1.19",
"symfony/twig-bridge": "^2.7"
},
...
Don't forget to run composer update after you make changes to composer.json.

Composer: multiple vendor directories (zend seperate dir than doctrine,...)

I've new to composer and I searched a few hours on the internet to find a solution for my problem, I've found one but can't get it to work so it's probably me.
I'm starting a new project with zend framework 1.12.3 and some extra vendors like doctrine. I don't mind that doctrine, phpunit, ... are installed in the default /vendor (or if I set another) but I rather have Zend on library/Zend instead of vendor/zendframework/....
I'm new to composer so I could've missed something.
Original:
{
"name": "Awesome",
"require": {
"zendframework/zendframework1": "1.12.3",
"doctrine/orm": "2.3.4",
"doctrine/dbal": "2.3.4"
},
"require-dev": {
"phpunit/phpunit": "3.7.21",
"mockery/mockery": "dev-master#dev"
}
}
I also tried it with https://github.com/composer/installers
{
"name": "Awesome",
"require": {
"composer/installers": "~1.0"
"zendframework/zendframework1": "1.12.3",
"doctrine/orm": "2.3.4",
"doctrine/dbal": "2.3.4"
},
"require-dev": {
"phpunit/phpunit": "3.7.21",
"mockery/mockery": "dev-master#dev"
},
"extra": {
"installer-paths": {
"library/Zend": ["zendframework/zendframework1"]
}
}
}
If it's a too big hastle to do it I can install zend locally so that's not a problem but it would be nice to do it with composer at once.
As explained in the comments, its not possible to install different packages in different(custom) locations.
the installer-paths does not work, as the zend package is not of a supported type (I think this works only for wordpress packages)
For your problem this is not a real problem. Zend Server sure does nothing special, only because the libraries are placed in this specific place. Also they had enough time to fix things for composer, if they really had some.
But, even if its not a solution for placing the Zend framework in this specific place, its possible to have multiple composer.json in different directories. You only need to add both autoload.php files. Thats no problem, as composer supports autoloading for multiple usage as this.

Categories