I updated my composer.json file to include dbunit:
"require-dev": {
"phpunit/phpunit": "^7",
"phpunit/dbunit": "^1"
},
I ran composer and it updated my installation to include dbunit (I already had PHPUnit).
But when I tried to add the TestCaseTrait namespace to my test the IDE claims it can't find that namespace.
use PHPUnit\Framework\TestCase; <----- this works great
use PHPUnit\DbUnit\TestCaseTrait; <----- error that namespace doesn't exist
Am I missing a step?
I was able to reproduce your problem with this in my composer.json:
"phpunit/dbunit": "^1"
By increasing the version to ^4, the namespace is no longer unfindable. Keep this in mind, if you didn't already know about the composer json schema:
The caret will update you to the most recent major version (the first number).
^1.2.3 will match any 1.x.x release including 1.3.0, but will hold off on 2.0.0.
Here's the working composer.json I used:
{
"require-dev": {
"phpunit/phpunit": "^7",
"phpunit/dbunit": "^4"
}
}
Related
I have installed the package from composer I am trying to include file from vendor folder into controller but it does not including.
Here is what I am trying
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use src\Coinpayments;
use src\keys;
class CoinController extends Controller
{
public function DoIt(){
$cps = new CoinPaymentsAPI();
}
}
And this is in composer.json
"require": {
"php": "^7.1.3",
"coinpaymentsnet/coinpayments-php": "^1.0",
"fideloper/proxy": "^4.0",
"laravel/framework": "5.8.*",
"laravel/tinker": "^1.0"
},
In the result I am getting following error which is
Class 'App\Http\Controllers\CoinPaymentsAPI' not found
After a composer install it's advised to run
composer dump-autoload
In the instructions from the package they tell you to include the following file:
require('/your_installation_path_to/src/CoinpaymentsAPI.php');
You aren't including it correctly, pretty sure your IDE is giving you errors.
It's probably, I found this information in the composer.json file included in the package:
use Coinpaymentsnet\CoinpaymentsAPI
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
I upgrated my project from laravel 5.4 to laravel 5.5 ,
I dont have any problem in local env but in server i get this exception ,
I searched a lot and i know this issue may be duplicated but no solutions solved my problem!
How can i not registering dusk when environment is production?
i wrote this code in AppServiceProvider.php :
public function register()
{
// Dusk, if env is appropriate
if ($this->app->environment('local', 'testing')) {
$this->app->register(DuskServiceProvider::class);
}
}
but it seems not working.
can anyone help?
EDITED :
my composer.json file:
"require-dev": {
"filp/whoops": "~2.0",
"fzaninotto/faker": "~1.4",
"mockery/mockery": "1.*",
"phpunit/phpunit": "^7.0.3",
"symfony/css-selector": "4.0.*",
"symfony/dom-crawler": "4.0.0",
"barryvdh/laravel-ide-helper": "^2.4",
"laravel/dusk": "^2.0"
},
The Exception is :
Exception
It is unsafe to run Dusk in production.
In Laravel 5.5, packages are automatically discovered and loaded so you will probably need to tell it not to load dusk.
One way is to add this to your composer.json
"extra": {
"laravel": {
"dont-discover": [
"laravel/dusk"
]
}
},
Also, you can add it to your dev dependencies and when you deploy in production, use:
composer install --no-dev
Taylor wrote an article about it here.
Look, it does not work because it is configured to work on local and testing environment.
I guess that you need to add 'production' (if your production is called 'production in your .env file environment:
AppServiceProvider
public function register()
{
// Dusk, if env is appropriate
if ($this->app->environment('local', 'testing', 'production')) {
$this->app->register(DuskServiceProvider::class);
}
}
When installing to production server I just needed to use the --no-dev flag
composer install --no-dev
Good luck!
If you're experiencing this problem while in a developing environment and accidentally landed here due to the title, you should check that your .env file is set up for development. It should contain the line
APP_ENV=local
Here is an example of how the .env file could look: https://github.com/laravel/laravel/blob/master/.env.example
And here is the Laravel documentation: https://laravel.com/docs/5.7/configuration
Also, in composer.json, laravel/dusk should be listed under require-dev and not require.
Check whether file which named .env contained in the source folder and setup Database user name and password and other settings.
I had the same problem because I have set all the things but forgot to change the .env.example to .env
When running codecept run -vvv I get an error stating that the actor is undefined in the SuiteManager class (method is initialize).
Any guess on how to fix this?
I've set up two basic unit tests where I just want to assert some values, and they worked until I switched to the composer autoloader.
In the composer.json I have the following:
"autoload": {
"classmap": [
"app"
]
},
"require-dev": {
"codeception/codeception": "^2.3",
"phpstan/phpstan": "^0.8.0",
"symfony/console": "^3.3"
}
In the main _bootstrap file provided by Codeception I only have a require_once for the vendor autoloader file.
Using php 7.1 and latest versions of the packages.
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.