Class not found on remote server

1

I have the following file index.php

<?php

  require_once 'global/erros/erros.ini';   
  require_once 'vendor/autoload.php';  

  use CLASSES\INIT\Init; 

  new Init();

?> 

And the following class Init.php

<?php

  namespace CLASSES\INIT;

  use CLASSES\CONFIG\Config;

  class Init extends Config {   

    protected function iniciaRotas() {

        $ar["home"]     = array("rota"=>"/crud/", "controle"=>"site", "acao"=>"index");
        $ar["index"]    = array("rota"=>"/crud/index", "controle"=>"site", "acao"=>"index");
        $ar["admin"]    = array("rota"=>"/crud/admin", "controle"=>"admin", "acao"=>"index");

        $this->configRotas($ar);

   }

  }
?> 

And the following autoload_ps4

<?php

// autoload_psr4.php @generated by Composer

$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);

return array(
    'CLASSES\' => array($baseDir . '/classes'),
);

So, locally (localhost) works.

But when I upload to the server it gives an error:

Fatal error: Class 'CLASSES\INIT\Init' not found in 
/var/www/html/funerariasaopedro.net.br/web/crud/index.php on line 8

It does not make much sense!

Tree

\
\index.php
\classes\
\classes\init\
\classes\init\Init.php

How did I stop at composer.json to generate autoload_psr4.php ?

In this way:

'CLASSES\UTIL\'  : '/classes/util',
'CLASSES\MVC\CONTROLES\'  : '/classes/mvc/controles'

Or this?

'CLASSES\UTIL\Util\'  : '/classes/util/Util.php',
'CLASSES\MVC\CONTROLES\Administradores\'  : '/classes/mvc/controles/Administradores.php',
'CLASSES\MVC\CONTROLES\Base\'  : '/classes/mvc/controles/Base.php'
    
asked by anonymous 19.06.2018 / 15:50

1 answer

0

Locally it should be working because Windows is usually case-insensitive.

On the server, which must be linux-based, it will be case-sensitive.

You can change the vendor/autoload.php to always convert the path to lowercase, if that is always your rule, or else change the use CLASSES\INIT\Init; to represent what is in the filesystem, but then you will probably have to change in several files.

Also note that the% w / o% you are using was generated by% change% change this file may have other consequences.

    
19.06.2018 / 16:09