Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

632
Visualizações
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 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda