I have a project that was developed without namespaces and with a "private framework" written by my team at the time. Said framework depends on an autoload function that includes files from within the framework and automatically finds files inside the project, which means that inside the project we have 0 includes/requires. Every file follows a specific rule and gets included by my function.
Everytime we would use third-party library, we would download the files and place them at a specific place and work on getting the files property loaded.
This week I found a new library I wanted to use, so I decided to install it via composer. Now my autoload function doesn't exist and my framework stops any execution at the begin for missing files.
How do I go about keeping my autoload as is (that includes files without namespaces from my project and my framework) and still use composer? Is it possible or I'm dead?
Edit: Adding some files to the question.
frameworkBootstrap - This file loads the framework (works just fine).
<?php
$dir = dirname(__FILE__);
// Database Package
require $dir . '/nav/database/NavDao.php';
require $dir . '/nav/database/NavDatabase.php';
require $dir . '/nav/database/NavTable.php';
// General
require $dir . '/nav/general/NavLanguage.php';
require $dir . '/nav/general/NavProject.php';
require $dir . '/nav/general/NavController.php';
// Tool
require $dir . '/nav/tool/NavValidator.php';
require $dir . '/nav/tool/NavLogger.php';
require $dir . '/nav/tool/NavListener.php';
require $dir . '/nav/tool/NavFile.php';
require $dir . '/nav/tool/NavEmail.php';
require $dir . '/nav/tool/NavException.php';
// View
require $dir . '/nav/view/NavPage.php';
require $dir . '/nav/view/NavTemplate.php';
require $dir . '/nav/view/NavView.php';
// Request
require $dir . '/nav/request/NavRequest.php';
require $dir . '/nav/request/NavAccess.php';
require $dir . '/nav/request/NavResponse.php';
require $dir . '/nav/request/NavSession.php';
// Plugin
NavProject::plugin(
array(
'NavMail' => $dir . '/nav/plugin/email/NavMail.php',
'NavXPertMailer2006' => $dir . '/nav/plugin/email/NavXPertMailer2006.php',
'NavLog' => $dir . '/nav/plugin/log/NavLog.php',
'NavImage' => $dir . '/nav/plugin/file/NavImage.php',
'NavMysql' => $dir . '/nav/plugin/dbms/NavMysql.php',
'NavOracle' => $dir . '/nav/plugin/dbms/NavOracle.php',
'NavTranslate' => $dir . '/nav/plugin/translate/NavTranslate.php'
));
require $dir . '/vendor/autoload.php';
?>
Autoload funciton - This funciton is being replaced.
function __autoload($className) {
$file = '';
// Auto Load Template
if (strpos($className, 'Template') !== false)
$file = NavProject::path() . 'class/view/template/' . $className . '.php';
// Auto Load Project Tools
else if (strpos(strtolower($className), strtolower(NavProject::name())) !== false)
$file = NavProject::path() . 'class/tool/' . $className . '.php';
// Auto Load Controllers
else if (strpos($className, 'Controller') !== false)
$file = NavProject::path() . 'class/control/' . $className . '.php';
// Auto Load Nav Plugin
else if (strpos($className, 'Nav') === 0) {
$list = NavProject::plugin();
foreach ($list as $plugin => $location)
if ($plugin == $className)
$file = $location;
// Auto Load Model
} else {
$file = NavProject::path() . 'class/model/' . $className . '.php';
}
if (is_file($file))
require $file;
}
require $dir . '/vendor/autoload.php';
. The file that has my autoload function is the NavRequest, also loaded by the FrameworkBoostrap (5th group, 1st file). – Marco Aurélio Deleu