Support the ongoing development of Laravel.io →
posted 10 years ago
Packages

Hi to all!

I want to create a test package. As in example, my test service is located in "vendor\test" directory (filename TestServiceProvider.php)

<?php namespace Test;

use Illuminate\Support\ServiceProvider;

class TestServiceProvider extends ServiceProvider {

	/**
	 * Bootstrap the application services.
	 *
	 * @return void
	 */
	public function boot()
	{
		//
	}

	/**
	 * Register the application services.
	 *
	 * @return void
	 */
	public function register()
	{

	}

}

and add a

'providers' => [

		'Test\TestServiceProvider',
],

But when i run an application, it show me

FatalErrorException in compiled.php line 6444:
Class 'Test\TestServiceProvider' not found.

How to fix this?

PS. php composer.phar dump-autoload was executed, but the same error.

Thanks in advance.

Last updated 3 years ago.
0

Are you creating the test folder inside vendor folder ? It's not a good very idea to create your own folders inside vendor folder. What i normally do is create a folder call it "Lib" on the same level as app folder and add it to composer.json so composer will generate autoload namespaces for my library.

also the preferred method of file structure is

/app
/vendor
    /yourname
        /library
    /esomkin
        /test

your class namespace should be <?php namespace Esomkin/Test;

Last updated 10 years ago.
0

astroanu said:

Are you creating the test folder inside vendor folder ? It's not a good very idea to create your own folders inside vendor folder. What i normally do is create a folder call it "Lib" on the same level as app folder and add it to composer.json so composer will generate autoload namespaces for my library.

also the preferred method of file structure is

/app
/vendor
   /yourname
       /library
   /esomkin
       /test

your class namespace should be <?php namespace Esomkin/Test;

It's mostly clear, but some moments in dark :) Can you give me an example of creating simple package in Laravel 5?

0

I found http://kodeinfo.com/post/laravel-4-5-package-development and http://stackoverflow.com/questions/28378460/laravel-5-package-development, but as I know workbench is removed from Laravel 5, so I want to solve my problem without workbench.

Last updated 10 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

esomkin esomkin Joined 18 Mar 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.