php add facebook sdk to the composer - php

I am reading this official facebook https://developers.facebook.com/docs/php/gettingstarted/4.0.0 page.
I want to add the facebook sdk to my project
I tried to do this:
composer require facebook/php-sdk in the root of my project and I got this
Warning: This development build of composer is over 30 days old. It is recommend
ed to update it by running "C:\ProgramData\ComposerSetup\bin\composer.phar self-
update" to get the latest version.
Please provide a version constraint for the facebook/php-sdk requirement: **4**
as you see, I have chosen 4, then I got this error message:
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- The requested package facebook/php-sdk could not be found in any version,
there may be a typo in the package name.
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your min
imum-stability setting
see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> f
or more details.
Read <http://getcomposer.org/doc/articles/troubleshooting.md> for further common
problems.
Installation failed, reverting ./composer.json to its original content.
why is that please? notice please that I didn't add anything to my composer.json.
I opened the composer.json and I found this line:
"require": {
"laravel/framework": "4.2.*"
},
so should I change it to :
"require": {
"laravel/framework": "4.2.*",
"facebook/php-sdk-v4" : "4.0.*"
},
or should I keep it and add a new require entity like this:
"require" : {
"facebook/php-sdk-v4" : "4.0.*"
}

just try and add facebook/php-sdk-4 to your existing require hash and then run composer update.
"require": {
"laravel/framework": "4.2.*",
"facebook/php-sdk-v4" : "4.0.*"
}

Related

Composer update error on friendsofsymfony/http-cache-bundle

i wanted to install the following packages for the Symfony Framework 3.4 with help of the composer package manager:
friendsofsymfony/http-cache-bundle
guzzlehttp/psr8
php-http/guzzle6-adapter
I dont have much experience with composer. I saw that those packages are installable under Symfony 3.4 in a tutorial. I even tried installing every component of the bundle one by one, quitting with the bellow error message for example (guzzlehttp/psr7). When installations failed why are the packages then in my composer.json file under require ?
Here is my composer.json:
"require": {
"php": ">=7.1.3",
"friendsofsymfony/http-cache": "^2.5.2",
"friendsofsymfony/http-cache-bundle": "^2.6",
"guzzlehttp/psr7": "^1.5",
"php-http/guzzle6-adapter": "^2.0",
I am getting this error message:
Errror message
Error message installing (guzzlehttp/psr7):
Errror message
Thanks in advance.
You executed composer update, so probably you have added packages manually in the composer.json
composer update won't change what is inside composer.json.
upgrade: Upgrades your dependencies to the latest version according to composer.json, and updates the composer.lock file.
See https://getcomposer.org/doc/01-basic-usage.md for mroe details.
Shortcut for "add if possible" is the command composer require
Exmaple:
composer require friendsofsymfony/http-cache
This will try to install the package. composer.* files will be updated only on successful installation.

How do I use my forked version of a repo in Composer?

I was working on a project and ended up having to make a small change to one of the packages I'm using.
That package is: shopifyextras/shopify-php-api-wrapper
Which you can find here: https://github.com/ShopifyExtras/PHP-Shopify-API-Wrapper
My previous composer.json file looked like this:
{
"require": {
"monolog/monolog": "1.*",
"shopifyextras/shopify-php-api-wrapper": "^1.1"
},
"autoload": {
"psr-0": { "MyApp\\": "src/" }
}
}
After forking the repo and making my changes (I forgot to create a new branch first, but created the branch after committing to master, and pushed it to github - I don't think this should cause any issues given that the branch exists and it does point to the correct head), I then updated my composer.json to use my fork.
After reading the composer docs (https://getcomposer.org/doc/05-repositories.md#vcs) I updated my composer.json to the following:
{
"minimum-stability": "dev",
"prefer-stable" : true,
"repositories": [
{
"type": "git",
"url": "https://github.com/JonLaliberte/PHP-Shopify-API-Wrapper.git"
}
],
"require": {
"monolog/monolog": "1.*",
"shopifyextras/shopify-php-api-wrapper": "dev-risksbugfix"
},
"autoload": {
"psr-0": { "MyApp\\": "src/" }
}
}
When I run composer update I receive the following error:
$ composer update --verbose
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- The requested package shopifyextras/shopify-php-api-wrapper could not be found in any version, there may be a typo in the package name.
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum-stability setting
see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.
Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.
I have tried:
Using "risksbugfix" instead of "dev-risksbugfix"
Using type "vcs" instead of git"
Removing ".git" from the repo URL
Using "jonlaliberte/shopify-php-api-wrapper" instead of "shopifyextras/shopify-php-api-wrapper"
Any help would be greatly appreciated. Thanks!
Branch Alias
If you alias a non-comparable version (such as dev-develop) dev- must
prefix the branch name.
You branch is a non-comparable version dev-riskbugfix.
You might need to prefix it with dev-: dev-dev-riskbugfix.
Or rename the branch to riskbugfix and get rid of the dev-, then the alias would be dev-riskbugfix.

How do I use the latest version of Zend Framework 2.3.5 using Composer PHP?

What do I add in my Composer.json file so it downloads version 2.3.5 of the Zend Framework? I've tried reading the Zend docs but it doesn't mention Composer.
{
"require" : {
"silex/silex": "~1.1",
"monolog/monolog": "~1.7",
"aws/aws-sdk-php": "~2.6",
"zendframework/zendservice-amazon": "2.3.5"
},
"require-dev": {
"heroku/heroku-buildpack-php": "*"
},
"repositories": [
{
"type": "composer",
"url": "https://packages.zendframework.com/"
}
]
}
After I run composer update, it gives me this error message:
C:\Users\Ricky\graffiti-galore>composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- The requested package zendframework/zendservice-amazon could not be found in any version, there may be a typo in the package name.
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum-stability setting
see https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion for more details.
Read http://getcomposer.org/doc/articles/troubleshooting.md for further common problems.
In your require statement, it looks like you're using the wrong include for Zend. In your require statement:
"zendframework/zendservice-amazon": "2.3.5"
should be
"zendframework/zend-config": "2.3.5",
"zendframework/zend-http": "2.3.5"
Or if you want to avoid requiring a specific version number,
"zendframework/zend-config": "2.*",
"zendframework/zend-http": "2.*"
and for the part in minimum stability
"minimum-stability": "dev"
zendservice-amazon is not part of Zend Framework 2, none of the ZendService libs are. Its latest version is 2.0.3, all versions are listed here: https://packagist.org/packages/zendframework/zendservice-amazon
There is no version 2.3.5 for zendframework/zendservice-amazon, so obviously the install fails. Look at https://packagist.org/packages/zendframework/zendservice-amazon to see the available versions and fix the version selector (I'd suggest ~2.0).
You also don't need the repositories part in your composer.json, all the packages are also on Packagist, Composer's main and default package repository.

How to get the (new) Azure PHP SDK to work?

I've got the old PHP azure SDK working on a Azure website, but I would like to migrate to the new one. Unfortunately, I'm unable to get the new one to work.
I've installed the SDK manually and followed the "Usage" steps on this page: https://github.com/Azure/azure-sdk-for-php. Instead of 'use' I use 'require', maybe that's where it goes wrong but I don't know how to use namespaces.
The environment I use to edit my code is dreamweaver.
The following code goes wrong at the line starting with $tableRestProxy
<?php
require("WindowsAzure/WindowsAzure.php");
require("WindowsAzure/Common/ServicesBuilder.php");
require("WindowsAzure/Common/ServiceException.php");
require("WindowsAzure/Table/TableRestProxy.php");
$connectionString = 'DefaultEndpointsProtocol=https;AccountName=[AccountName];AccountKey=[AccountKey]';
// I do know that I have to declare the AccountName and AccountKey here. Left it out for privacy reasons.
$tableRestProxy = ServicesBuilder::getInstance()->createTableService($connectionString);
?>
update
Now I'm trying to use Composer to install the SDK. My composer.json file looks like this:
{
"require": {
"microsoft/windowsazure": "*"
},
"repositories": [
{
"type": "pear",
"url": "http://pear.php.net"
}
],
"minimum-stability": "dev"
}
When I run the composer.phar I get the following result:
Onwijs#JEROENVINK /e/Users/Public/Documents/00_speeltuin_azure/newsdk
$ php composer.phar diagnose
Checking composer.json: OK
Checking platform settings: FAIL
The xdebug extension is loaded, this can slow down Composer a little.
Disabling it when using Composer is recommended, but should not cause issues bey
ond slowness.
Checking git settings: OK
Checking http connectivity: OK
Checking disk free space: OK
Checking composer version: OK
Onwijs#JEROENVINK /e/Users/Public/Documents/00_speeltuin_azure/newsdk
$ php composer.phar install
Loading composer repositories with package information
Initializing PEAR repository http://pear.php.net
Installing dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for microsoft/windowsazure 0.4.0 -> satisfiable by mi
crosoft/windowsazure[v0.4.0].
- microsoft/windowsazure v0.4.0 requires pear-pear/http_request2 * -> no mat
ching package found.
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your min
imum-stability setting
see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> f
or more details.
Read <http://getcomposer.org/doc/articles/troubleshooting.md> for further common
problems.
I don't see what I'm doing wrong.
There seems to be a problem with pear and the Azure SDK via composer.
I found a way around it by modifying my composer.json file to look something like this:
{
"require": {
"microsoft/windowsazure": "*",
"pear-pear.php.net/http_request2": "*",
"pear-pear.php.net/mail_mime": "*",
"pear-pear.php.net/mail_mimedecode": "*"
},
"repositories": [
{
"type": "pear",
"url": "http://pear.php.net"
}
],
"minimum-stability": "dev"
}
Notice the three lines:
"pear-pear.php.net/http_request2": "*",
"pear-pear.php.net/mail_mime": "*",
"pear-pear.php.net/mail_mimedecode": "*"
these provide more explicit information to composer and using this approach things seem to compose just fine.
Hope that helps.

Yii2 installation using composer giving error

I am trying to install Yii2 alpha. When I run the following command after downloading composer and adding
"minimum-stability": "dev"
to composer.json.
$ php composer.phar require yiisoft/yii2-framework "*"
I get the following error.
Problem 1
- The requested package minimum-stability could not be found in any version, there may be a typo in the package name.
Problem 2
- The requested package yiisoft/yii2-composer could not be found in any version, there may be a typo in the package name.
Problem 3
- The requested package yiisoft/yii2-framework could not be found in any version, there may be a typo in the package name.
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum-stability setting
see https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion for more details.
Read http://getcomposer.org/doc/articles/troubleshooting.md for further common problems.
Please help me.
start with
php composer.phar init
and set Minimum Stability[] to dev
then
php composer.phar require yiisoft/yii2 "*"
Here is working composer.json code
{
"name": "yiisoft/yii2-app-advanced",
...
"minimum-stability": "dev",
"require": {
"php": ">=5.4.0",
"yiisoft/yii2": "*",
},
"require-dev": {
"yiisoft/yii2-debug": "*",
"yiisoft/yii2-gii": "*"
},
...
}
Use yii2 against yii2-framework, may be you typed "minimum-stability" in the wrong place. And you don't need type yii2-composer there, it will be installed automatically

Categories