1
Good night (or any shift in case you’re from the future).
Well, my problem is objective, but so far unsolved.
I developed an entire project on my windows PC using XAMPP.
As the system has several classes I am using autoload from Composer as follows:
"autoload": {
"psr-4": {
"persistencia\\": "libs/persistencia/",
"sistema\\": "libs/sistema/"
}
}
Folder structure:
libs
├── persistencia
│ ├── categoriaproduto.php
│ ├── cliente.php
│ ├── contrato.php
│ ├── funcionario.php
│ ├── itemcontrato.php
│ ├── mensageiro.php
│ ├── modelodados.php
│ ├── persistenciaexception.php
│ ├── persistencia.php
│ ├── produto.php
│ ├── relatorio.php
│ └── tipoacesso.php
└── sistema
├── logger.php
├── sistemaexception.php
└── sistema.php
Running the system in XAMPP here in my Win was all ok. The problem occurs when I have prepared a server Ubuntu, apache, mysql, php7.2.
I installed Composer, downloaded the files from my site I ran "Composer install" and the result was:
Uncaught Error: Class 'system System' not found in /var/www/html/api.php:18
The code in question is this:
<?php
require_once('vendor/autoload.php');
require_once('../config.php');
if(Config::REQUISITAR_LOGIN) // Se for nescesário estar logado para usar o sistema
testarLogin(); //Impedindo acesso de usuários não logados
header('Content-Type: application/json');
if(Config::CORS) //Checando se deve ou não habilitar Cross Origin
header("Access-Control-Allow-Origin: *");
if(!Config::EXIBIR_ERROS) {// Impedindo ou não a exibição de erros
error_reporting(0);
ini_set('display_errors', 0);
}
use sistema\Sistema;
try {
$sistema = new Sistema; /*ESSA É A LINHA 18 QUE DEVIA FUNCIONAR*/
} catch(Exception $e) {
echo '{"status": "falha", "erro": "'.$e->getMessage().'"}';
exit(0); // A API não pode funcionar sem o sistema
}
The problem should not be in how I wrote the Composer, as it was working until I changed the platform.
Finally, I couldn’t find any answers that could help me, so thank you to whoever volunteers.
The class file
Sistemaseems to besistema, which is wrong for Composer. The file must have the same class name.– Woss