Skip to content

Instantly share code, notes, and snippets.

@seothemes
Last active September 9, 2019 00:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seothemes/d2ab24023ee8ca80134077d336453cda to your computer and use it in GitHub Desktop.
Save seothemes/d2ab24023ee8ca80134077d336453cda to your computer and use it in GitHub Desktop.
Simple PSR-4 autoloader
<?php
\spl_autoload_register( function ( $class ) {
if ( strpos( $class, __NAMESPACE__ ) !== false ) {
require_once __DIR__ . '/src' . str_replace( '\\', DIRECTORY_SEPARATOR, substr( $class, strlen( __NAMESPACE__ ) ) ) . '.php';
}
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment