Class 'Pimple\Container' not found - php

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.

Related

Why does 'composer dumpautoload -o' fix 'Class not found' PHP error?

I have a Laravel 5.8 project that is dependent on a private package.
When I run composer install the package is installed and shows up in the vendor folder.
project composer.json
{
...
"require": {
"php": ">=7.0",
"company/api-request": ">=1.0.0"
}
...
}
package src/ApiRequest.php
<?php
namespace Company;
class APIRequest
{
...
}
package composer.json
{
...
"autoload": {
"psr-4": {
"Company\\": "src/"
}
}
...
}
When I call the package
\Company\APIRequest::run();
I am getting
Message: Class 'Company\APIRequest' not found
I know the PHP syntax is correct because when I run composer dumpautoload -o the error is gone, but why is it necessary?
I expect composer install or composer update should be sufficient; I have no problem with external packages.
Am I missing anything here?
If the class name and file name don't match, that would cause the auto-loading to not work since that is a requirement with PSR-4. From the docs:
The terminating class name corresponds to a file name ending in .php. The file name MUST match the case of the terminating class name.
If that's the case, composer dumpautoload -o is probably working around this for you, see this Reddit post:
The reason -o works, is Composer creates a giant associative array where classname = filename

Missing 'Illuminate\Routing\ControllerServiceProvider' class on Laravel 5.2

I have updated the composer.json file as instructed on the upgrade guide on Laravel 5.2 Documentation and run composer update.
Everything was updated correctly, but composer dumped the error below while generating autoload files.
Class 'Illuminate\Routing\ControllerService Provider' not found in /home/vagrant/Code/homework/vendor/laravel/framework /src/Illuminate/Foundation/ProviderRepository.php on line 146
Make sure you remove Illuminate\Routing\ControllerServiceProvider from your /config/app.php.
https://www.laravel.com/docs/5.2/upgrade (see the "Service Providers" section)
Problem is with your composer.json.It may got corrupted. Make sure
"require": {
"laravel/framework": "5.2.*"
},
exists.Then run composer update.

work with composer in php

hi I have a problem in adding illuminate/html to my laravel project in my composer.json file. I've added this code to composer.json:
"require": {
"illuminate/html": "~5.0"
},
I think after doing this, I should execute:
composer update
in cygwin in the folder of my project. When I do this, I get this error:
Composer could not find the config file: C:\ProgramData\ComposerSetup\bin
please help me thanks.

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": [
"..."
]
}

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