Skip to content

Instantly share code, notes, and snippets.

@Bolinha1
Created June 18, 2014 13:30
Show Gist options
  • Select an option

  • Save Bolinha1/ea21a4fe9f5cf41ff6ab to your computer and use it in GitHub Desktop.

Select an option

Save Bolinha1/ea21a4fe9f5cf41ff6ab to your computer and use it in GitHub Desktop.
autoload
<?php
$whereAmI = dirname(realpath(__FILE__)). DIRECTORY_SEPARATOR;
set_include_path(
implode(
PATH_SEPARATOR,
// Retorna o array sem dados duplicados
array_unique(
array_merge(
array(
$whereAmI . 'app',
),
explode(PATH_SEPARATOR, get_include_path())
)
)
)
);
spl_autoload_register(
function ($qname)
{
$qname2path = stream_resolve_include_path(
str_replace('\\', DIRECTORY_SEPARATOR, $qname) . '.php');
if ($qname2path !== false) {
require $qname2path;
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment