ProcessOut integration without composer - php

I'm trying to integrate processout but they only seem to support composer integration.
https://github.com/ProcessOut/processout-php
How would I integrate this just by uploading the /src/ folder into my project?
<?php
// Load dependencies
require 'vendor/autoload.php';
// Instantiate ProcessOut
$processout = new \ProcessOut\ProcessOut();
$processout->setProjectId('<project-id>');
$processout->setProjectSecret('<project-key>');
// Set this project as the default one for the current request
\ProcessOut\ProcessOut::setDefault($processout);
?>

You are ignoring that Composer is not an autoloader generator, but first and foremost a dependency manager. If you look at the composer.json file of the ProcessOut package you see:
"require": {
"php": ">=5.4",
"ext-curl": "*",
"ext-mbstring": "*",
"anlutro/curl": "1.4"
},
The last line is a package it depends on itself, and that you'll be missing out when not using Composer. You could theoretically load and include all dependencies recursively yourself, but in the end - just get composer and let it do its work.

They have a php release where you only have to load autoload.php:
https://github.com/ProcessOut/processout-php/releases

Related

composer: replace dependencies with local versions

I want to use a library that defines some extensive dependencies in its composer.json file, even though it only uses one or two small classes of those dependencies.
Is it possible to set up my require in a way that composer thinks I already have those dependencies and lets me use some self-defined minimal mock classes instead?
Example: I want package lib/a which in turn requires lib/b.
Normally I would have something like this in my composer.json:
"require": {
"lib/a": "^2.2"
}
I thought that maybe 'provide' would fool composer:
"require": {
"lib/a": "^2.2"
},
"provide": {
"lib/b": "2.2.0"
}
But it seems to do nothing. Composer still downloads lib/b.
Is there any way to tell composer to ignore a certain dependency?
Turns out replace does what I want:
"require": {
"lib/a": "^2.2"
},
"replace": {
"lib/b": "*"
}
This tells composer that the package at hand replaces any version of lib/b

Composer: library which requires a library

I am trying to create a PHP library which includes other libraries, and I bet I'm missing something fundamental.
Using the AWS PHP SDK as a guide, I'd like to create a library which, after installing with Composer, requires other libraries, yet the entire scope of classes (both from the current library, and required libraries) all become available simply by using require 'vendor/autoload.php;'.
What are the basic requirements to set this up? Is it a matter of configuring composer.json, namespacing in a particular way, or both?
What you're describing is exactly Composer's main purpose - the definition of a package of code that may require and implement other packages.
Using the AWS SDK as a guide, if you look at the composer.json file, which provides all of the Composer configuration information, you'll see two require blocks, one labeled require and one labeled require-dev:
"require": {
"php": ">=5.5",
"guzzlehttp/guzzle": "^5.3.1|^6.2.1",
"guzzlehttp/psr7": "^1.4.1",
"guzzlehttp/promises": "~1.0",
"mtdowling/jmespath.php": "~2.2"
},
"require-dev": {
"ext-openssl": "*",
"ext-pcre": "*",
"ext-spl": "*",
"ext-json": "*",
"ext-dom": "*",
"ext-simplexml": "*",
"phpunit/phpunit": "^4.8.35|^5.4.0",
"behat/behat": "~3.0",
"doctrine/cache": "~1.4",
"aws/aws-php-sns-message-validator": "~1.0",
"nette/neon": "^2.3",
"andrewsville/php-token-reflection": "^1.4",
"psr/cache": "^1.0"
},
This is how you define what other packages/libraries your library depends upon. The require section lists all other libraries that must be installed when your library is installed. The require-dev section lists libraries that may only be necessary when you are working in a development environment, and are not needed in your production environment.
When you specify other libraries that are required, Composer will install your library, and then go out and also require the libraries your library requires (and then the libraries those libraries require, and so on and so on).
Also included with the libraries to include, you'll notice that the version numbers are also included, to ensure compatibility.
The easiest way to add new dependencies I find is on the command line, with the composer require command, documented here: https://getcomposer.org/doc/03-cli.md#require. The command helps you search for the package you want if you don't know it exactly, and can resolve the latest version for you automatically (which you can override if you need/want to).
If you wish to require a development-only dependency, add the --dev flag when running the command.
Using this command, Composer will automatically update your composer.json file, pull down the dependency onto the local machine, and update your autoloader.
You should never need to do anything more than require_once vendor/autoload.php to ensure dependencies can be autoloaded - Composer will do all the legwork of setting up the autoloader so you don't have to, and keep everything up to date as new dependencies are added.
Here's the complete documentation on the composer.json schema: https://getcomposer.org/doc/04-schema.md. You will want to have a composer.json config file in the root of project, so you can configure composer for your project (and any others that require your library later). If you don't have one, you can use the composer init command to interactively create one. Documentation on that command is available here: https://getcomposer.org/doc/03-cli.md#init
And here's their basic usage guide, in case you haven't gone through it already: https://getcomposer.org/doc/01-basic-usage.md

Composer cannot find the package for new require within Yii2 composer.json

Ok, I'm using Yii2 and I am trying to add a new requirement/library to the project. Said library can be found here: https://github.com/cyphix333/SBBCodeParser
It is a forked project with an added composer.json.
I tried adding it as a requirement in the projects main composer file, ie:
"require": {
//..........
"samclarke/sbb-code-parser": "*"
},
Then I ran:
composer update
It just complained that it couldn't find the package or any version of it.
Then I removed that line and tried:
require samclarke/sbb-code-parser
I have the files already in my Yii vendor folder located at: #app/vendor/samclarke/sbb-code-parser
I'm pretty new to composer and am not sure what I'm doing wrong or how composer actually is supposed to know where to get the files from based on the package name.
The package samclarke/sbb-code-parser can be found at Packagist.
https://packagist.org/packages/samclarke/sbb-code-parser
By default Composer tries to resolve a stableset of packages.
But this packages doesn't provide a stable version (version tag), yet - only the dev-master version exists. Composer can not resolve it.
In order to require it, you need to lower your minimum-stability for this package to development.
You might do this for one package explicitly:
"require": {
"samclarke/sbb-code-parser": "dev-master#dev"
},
Or for all packages by setting:
"minimum-stability": "dev"
The package cyphix333/SBBCodeParser is not on Packagist.
It's a private fork. If you want exactly this code. You might add a repositories section to your composer.json and add repo with url and type with vcs there. Then Composer can load the package from the VCS repository over at Github. This is described here: https://getcomposer.org/doc/05-repositories.md#loading-a-package-from-a-vcs-repository
That would work like this:
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/cyphix333/SBBCodeParser"
}
],
"require": {
"samclarke/sbb-code-parser": "dev-master"
}
}
But unfortunately, the fork is also not well maintained and doesn't contain a valid composer.json file.
[Composer\Repository\InvalidRepositoryException]
No valid composer.json was found in any branch or tag of https://github.com/cyphix333/SBBCodeParser, could not load a package from it.
This needs to be fixed first....

Class 'ZendService\Amazon\S3' not found even though it is installed via Composer

My project is based on the Zend Skeleton App, and I'm using Composer to add vendor packages. However, when I add the zendservice-amazon package, it is not getting autoloaded.
Here is part of my composer.json file:
"require": {
"php": ">=5.3.3",
"zendframework/zendframework": "2.3.*",
"zendframework/zendservice-amazon": "2.0.*",
"doctrine/doctrine-orm-module": "0.7.*",
"zf-commons/zfc-user-doctrine-orm": "dev-master"
}
I have looked at the autoload files in the vendor directory, and they include the ZendService\Amazon namespace. I've tried several different things, but it's not working.
I've double checked that composer's autoloader is being used, so this is really puzzling. Any ideas? Thanks in advance.
The documentation and examples are wrong in the Zend Framework documentation. Instead of:
$s3 = new \ZendService\Amazon\S3();
You need to add an extra "S3":
$s3 = new \ZendService\Amazon\S3\S3();

How to install downloaded version of Doctrine 2.2 ORM

I have downloaded the latest version of Doctrine ORM and on their site it says:
"See the configuration section on how to configure and bootstrap a downloaded version of Doctrine."
Then i go there ( http://docs.doctrine-project.org/en/latest/reference/configuration.html ) and i find at "class loading" section, that i have to add the following line to my project:
require_once "vendor/autoload.php";
Where's that autoload.php file? Where's the vendor folder? I don't get it...
Thanks.
When you downloaded the 'latest version' it included that autoload file. Locate it in the download and change the file path in the require_once function the the path of the file:
require_once "/location/of/files/you/downloaded/vendor/autoload.php";
As you can see about 400px down on the page here, you need to use to PEAR to install the files first:
http://www.doctrine-project.org/projects/orm.html
You can do it by installing composer first. Follow the guide in this page http://getcomposer.org/doc/00-intro.md. There's a description for Windows and Unix users, this will install composer, then create a json file that looks like this:
{
"require": {
"doctrine/orm": "2.*",
"symfony/yaml": "2.*"
},
"autoload": {
"psr-0": {"": "src/"}
}
}
Then from the cmd/terminal, run this command: composer install
You will find that the vendor folder is created automatically.

Categories