How to install downloaded version of Doctrine 2.2 ORM - php

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.

Related

Yii2: how to install multi-input widget

i have been trying to use this yii2-multiple-input widget but can't seem to be working. I have put the downloaded folder inside the vendor dir.
Error : Class 'unclead\multipleinput\MultipleInput' not found
The preferred way to install this extension is through composer.
Either run
php composer.phar require unclead/yii2-multiple-input "~2.0"
or add
"unclead/yii2-multiple-input": "~2.0"
to the require section of your composer.json file.

Composer Only Installs Packages w/ Manual Update to JSON File

When I use composer to install packages in my project I am only able to do so if I update my json file manually.
For example, if I run the following command in Git-Bash in my project directory (which contains my composer.phar and composer.json file):
php composer.phar require php-di/slim-bridge
It returns the following error:
[Invalid Argument Exception]
Could not find package
php-di\slim-bridge at any version for your minimum-stability (stable).
Check the package spelling or your minimum stability.
However, if i were to just update my json file to the following (example I've provided contains multiple packages I am using in my project):
{
"require": {
"slim/slim": "^3.0",
"slim/twig-view": "^2.1",
"illuminate/database": "^5.2",
"respect/validation": "^1.0",
"slim/csrf": "^0.6",
"slim/flash": "^0.1",
"phpmailer/phpmailer": "^5.2",
"php-di/slim-bridge":"^1.0"
},
"autoload":{
"psr-4": {
"App\\": "app"
}
}
}
... And I run the command: $ php.composer.phar update
Everything installs to project correctly.
What is going on that I am not able to install packages using the require method thus making me resort to manually updating my json file each time?
Since I am using windows, I used the windows installer for composer rather than install through command line and I got this working correctly. Much much easier now since I don't have to update my JSON files manually.

ProcessOut integration without composer

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

Class 'Pimple\Container' not found

I am trying to install Pimple in my project following https://github.com/silexphp/Pimple readme file.
Error message I receive is:
Fatal error: Class 'Pimple\Container' not found in E:\www\public\index.php on line 9
My composer.json file is:
{
...
"require-dev": {
"phpunit/phpunit": "5.1.*"
},
"require": {
"pimple/pimple": "~3.0"
}
}
When I do:
composer update
or
composer install
the message is: Nothing to install or update
In vendor/bin I can see only phpunit files. I can see however pimple in composer.lock
My PHP index.php file:
<?php
use Pimple\Container;
$co = new Container();
?>
Could you please help me make it work?
vendor/autoload.php was not included and this caused the error.
Try to delete Vendor content, and install dev again througth composer.

composer does not generate autoload.php

i install composer for windows using this link http://getcomposer.org/download/ > http://getcomposer.org/Composer-Setup.exe
my web server is WAMP php 5.4 with openssl enabled.
i created composer.json with this code
{
"require": {
"doctrine/orm": "*"
}
}
and run with this code in .php file
<?php
// bootstrap.php
// Include Composer Autoload (relative to project root).
require_once "vendor/autoload.php";
and i got error Warning: require_once(vendor/autoload.php): failed to open stream
how to get composer's autoload.php?
why composer does not generate it?
how to use doctrine without composer?
Did you actually look to see if a vendor/autoload.php was created?
Did composer throw any error messages? Unless you got an error then I'm willing to bet that a vendor/autoload files was made. Is there anything in vendor?
I'm guessing that your bootstrap.php is not in your root directory (same directory as composer.json). If so you need to adjust the path in your require statement.
Remove the autoload part from your composer.json, then run composer install
This will generate an updated autoload object, good luck!
"autoload": {
"classmap": [
"..."
]
}

Categories