I'm new to Laravel and PhpUnit and I'm trying to run some tests located in the \App\Tests\Unit folder on customs classes located in the \App\Musibits directory.
I get the following when I run phpunit in the \App\Tests\Unit directory:
Fatal error: Class 'Tonality' not found in C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\data\localweb\musibits\app\tests\TonalityTest.php on line 8
Tonality.php contains my class and is in the \App\Musibits directory
I read numerous posts about autoloading and bootstrap, but I can't seem to make it work :-(
Here is my composer.json
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"laravel/framework": "4.2.*"
},
"require-dev": {
"phpunit/phpunit": "3.7.*"
},
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php",
"app/musibits",
"app/tests"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
},
"minimum-stability": "stable"
}
There is three autoload files included with Laravel, one for composer, one for phpunit and one for Laravel, I didn't change any.
Any cues would be greatly appreciated.
Thanks,
Phil
You should probably run
composer dump-autoload
to generate new class map
Related
First time I try to add a package in the composer.json of my laravel application.
I trying to add this package paysafe https://github.com/paysafegroup/paysafe_sdk_php
I downloaded the repo and moved it under the folder "vendor" in laravel
It seem that I need to specific the version of the package I am trying to install , but I don't have this information ...
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"laravel/framework": "4.2.*",
"barryvdh/laravel-dompdf": "0.4.*",
"mailgun/mailgun-php": "~1.7.2",
"guzzlehttp/guzzle": "~4.0",
"mikehaertl/phpwkhtmltopdf": "^2.0",
"paysafe":"*"
},
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
},
"minimum-stability": "dev"
}
When I run this command
php composer.phar require paysafe
I get this error message:
[InvalidArgumentException]
Could not find package paysafe at any version for your minimum-stability (dev). Check the package spelli
ng or your minimum-stability
We have recently updated the SDK which should have fixed the version conflict issue. Please use PHP SDK version 1.0.1 and give it another shot!
All the best!
Basically a fresh git clone of a working repo...
When I try to composer install I get an error.
Seems like the laravel folders are not being installed the way composer expects to look for them? I tried updating/installing composer, deleting folders and clearing caches already.
I suspect I need to change composer.json or maybe revert to an older composer?
composer.json
"require": {
"laravel/framework": "4.2.*",
"zizaco/confide": "~3.2",
"zizaco/entrust": "~1.2",
"php": ">=5.3.0",
"ext-curl": "*",
"ext-json": "*",
"paypal/rest-api-sdk-php" : "*"
},
"require-dev": {
"barryvdh/laravel-debugbar": "~1.8",
"way/generators": "~2.6"
},
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
},
"minimum-stability": "stable"
[RuntimeException]
Could not scan for classes inside "[mysite]/vendor/laravel/framework/src/Illuminate/Queue/IlluminateQueueClosure.php" which does not appear to be a file nor a folder
I'm trying to install Stripe into my project but I'm having issues. I'm getting the error
Class 'Stripe' not found
I used
composer require stripe/stripe-php
and everything installed fine, but I'm still having issues.
This is the line that is causing the problem:
Stripe::setApiKey(Config::get('stripe.secret_key'));
This is my composer.json file:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"laravel/framework": "4.2.*",
"intervention/image": "dev-master",
"moltin/laravel-cart": "dev-master",
"stripe/stripe-php": "~2.0#dev"
},
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/libs",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
},
"minimum-stability": "dev",
"prefer-stable": true
}
There is nothing about Stripe in my app/config/app.php file... I'm not sure if there should be a service provider for Stripe.
Looking at packagist, you can see the composer package stripe/stripe-php point to the following GitHub repository. Based on that repository's code and the Stripe API documentation, it doesn't look like there's a global class named Stripe defined. So when you say
Stripe::setApiKey(Config::get('stripe.secret_key'));
and PHP says
Class 'Stripe' not found
PHP is telling you the truth. There is a class named Stripe\Stripe -- so you probably want to do this
\Stripe\Stripe::setApiKey(Config::get('stripe.secret_key'));
or import the class into your current PHP file with the use statement
<?php
//...
use Stripe\Stripe;
//...
Stripe::setApiKey(Config::get('stripe.secret_key'));
I created a brand new Laravel 5 application via laravel new mysite. When I open the site I see the following errors:
Notice: date_default_timezone_set(): Timezone ID '' is invalid in /mysite/storage/framework/compiled.php on line 1790
Fatal error: Call to undefined method Illuminate\Foundation\Bootstrap\ConfigureLogging::configureHandler() in /mysite/storage/framework/compiled.php on line 1656
Here is my composer.json:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"laravel/framework": "5.0.*"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-create-project-cmd": [
"php -r \"copy('.env.example', '.env');\"",
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
}
}
I've already ran composer update to make sure I have the latest dependencies, but I'm still getting the same error. Any ideas?
Edit: I'm using PHP 5.4
Edit 2: It works when running via php artisan serve but not when using my my dev box running apache to serve the site. So it could be a local php issue on that box.
I believe this issue has to do with your local server settings. I had the same issue on my local server and I set the value date.timezone in my php.ini
After downloading hybridauth from composer, I always need to manually add the hybridauth's directory in /vendor/composer/autoload_classmap.php, this should be automatic.
Below is my composer.json, can someone point me the problem why hybridauth is not getting written in autoload automatically?
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"require": {
"laravel/framework": "4.0.*",
"way/generators": "dev-master",
"hybridauth/hybridauth": "*",
"intervention/image": "dev-master"
},
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan optimize"
],
"pre-update-cmd": [
"php artisan clear-compiled"
],
"post-update-cmd": [
"php artisan optimize"
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
},
"minimum-stability": "dev"
}
Have you tried
using "hybridauth/hybridauth": "dev-master"
also try
artisan dump-autoload command
Looks like in the latest update they have changed lot of things and your old code won't work with it.
If you are not getting autoload classes in classmap file then better use older version of HybridAuth i.e. 2.9.1
use "hybridauth/hybridauth": "2.9.1" instead of "hybridauth/hybridauth": "dev-master"
Classes will be loaded automatically on autoload classmap file.
This works well on laravel 4 and 5 both.