0

I am new to laravel 4, and I am following a Laravel tutorial on Culttt.com right now. I added a package into the project and create a Facade to access: Philipbrown/Suypo, it works fine.

workbench\philipbrown\supyo\src\Philipbrown\Supyo\SuypoServiceProvider.phh

<?php namespace Philipbrown\Supyo;

use Illuminate\Support\ServiceProvider;

class SupyoServiceProvider extends ServiceProvider {

    protected $defer = false;

    public function boot()
    {
        $this->package('philipbrown/supyo');
    }

    public function register()
    {
        $this->app['supyo'] = $this->app->share(function($app)
        {
          return new Supyo;
        });
        $this->app->booting(function()
        {
          $loader = \Illuminate\Foundation\AliasLoader::getInstance();
          $loader->alias('Supyo', 'Philipbrown\Supyo\Facades\Supyo');
        });
    }

    public function provides()
    {
        return array('supyo');
    }

}

This is the composer.json file of my package:

{
"name": "philipbrown/supyo",
"description": "",
"authors": [
    {
        "name": "ChaoMeng",
        "email": "cmeng@idfbins.com"
    }
],
"require": {
    "php": ">=5.4.0",
    "illuminate/support": "4.2.*"
},
"autoload": {
    "classmap": [
        "src/migrations"
    ],
    "psr-0": {
        "Philipbrown\\Supyo": "src/"
    }
},
"minimum-stability": "stable"
}

But when I write some tests and use phpunit to run them, it shows this error:

Fatal error: Class 'Philipbrown\Supyo\SupyoServiceProvider' not found in C:\Dev\wamp\www\Culttt\laravel\vendor\laravel\framework\src\Illuminate\Foundation\ProviderRepository.php on line 158

I tried to run command: composer dump-autoload but it does not work. and I did not call or use this package in the test, so I really don't know what happens here, below is my test.php:

class CliqueTest extends TestCase {

    /**
     * Test that the name is required for Clique
     */
    public function testNameIsRequired()
    {
      // Create a new Clique
      $clique = new Clique;

      // Post should not save
      $this->assertFalse($clique->save());

      // Save the errors
      $errors = $clique->errors()->all();

      // There should be 1 error
      $this->assertCount(1, $errors);

      // The error should be set
      $this->assertEquals($errors[0], "The name field is required.");
    }

    public function testCliqueUserRelationship()
    {
      // Create a new Clique
      $clique = FactoryMuff::create('Clique');

      // Create two Users
      $user1 = FactoryMuff::create('User');
      $user2 = FactoryMuff::create('User');

      // Save Users to the Clique
      $clique->users()->save($user1);
      $clique->users()->save($user2);

      // Count number of Users
      $this->assertCount(2, $clique->users);
    }
}

So please give me a idea about what's going on. Thanks in advance.

This is the whole code in github: https://github.com/mc422/laravel.git

  • I think the problem is that your workbenches vendor folder needs to be inside of your "philipbrown/supyo" folder, not outside of it – Mitch Jul 08 '14 at 22:42
  • @MitchGlenn, I think I have the vendor folder in hte Supyo package, the vendor folder outside is just another package named vendor – user3818074 Jul 09 '14 at 14:15
  • I don't see a vendor folder inside of the Supyo package in the github repo you linked. The package should have a vendor folder with auto generated composer and illuminate folders – Mitch Jul 09 '14 at 15:40
  • Did you forget to run composer update? In your case PHPUnit uses vendor/autoload.php file to autoload classes. This file is being generated by composer when you run update, install or dump-autoload. Note that this should be run from the workbench\philipbrown\supyo directory. – Armen Markossyan Jul 17 '14 at 16:45

0 Answers0