• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

556
Vistas
Laravel resolving a new namespace - which files to add namespace data

In Laravel 4, in app/config/app.php, I find the following line under providers:

'Illuminate\Workbench\WorkbenchServiceProvider',

And that service provider works because I verify the register() method is called. I wondered how this maps out namespace-wise. It appears at least in part that the namespace Illuminate is declared here in /vendor/composer/autoload_namespaces.php:

'Illuminate' => array($vendorDir . '/laravel/framework/src'),

I have created a folder in /vendor called

/vendor/mycompany

And then create a class file called MyClass.php as follows

<?php namespace MyCompany;

#MyClass.php
class MyClass{
    ..etc..
}

I then add the same line in /vendor/composer/autoload_namespaces.php:

'MyCompany' => array($vendorDir . '/mycompany'),

And call the following in routes.php:

$test = new MyCompany\MyClass;      //line 15
print_r(class_get_methods($test));  //line 16

BUT, I get this error:

Fatal error: Class 'MyCompany\MyClass' not found in .. line 15

How do I solve this and get the namespace MyCompany registered and recognized?

over 3 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda