Composer automatically generates a “autoload.php” file. So, if you’re using Composer, then you’re all set! There’s nothing you need to do.

If you’re not using Composer, or if you’d like a faster autoloader, then go ahead and create this “lens/autoload.php” file. Here’s an example:

<?php call_user_func(function () { $projectDirectory = dirname(__DIR__); $classes = array( 'Example' => "{$projectDirectory}/src" ); foreach ($classes as $namespacePrefix => $libraryPath) { $namespacePrefix .= '\\'; $namespacePrefixLength = strlen($namespacePrefix); $autoloader = function ($class) use ($namespacePrefix, $namespacePrefixLength, $libraryPath) { if (strncmp($class, $namespacePrefix, $namespacePrefixLength) !== 0) { return; } $relativeClassName = substr($class, $namespacePrefixLength); $relativeFilePath = strtr($relativeClassName, '\\', '/') . '.php'; $absoluteFilePath = "{$libraryPath}/{$relativeFilePath}"; if (is_file($absoluteFilePath)) { include $absoluteFilePath; } }; spl_autoload_register($autoloader); } });

When you next run Lens, your new autoload file will be automatically discovered.

You can check your “settings.ini” file to see which “autoload” path Lens is using.