Search
 
SCRIPT & CODE EXAMPLE
 

PHP

composer autoload psr-4

"autoload": {
   "psr-4": {
        "Vendor": "src/"
    },
 },
Comment

custom autoload without composer php psr4

<?php
//custom autoload without composer
$to_map = [
    'App' =>  'app/',
    'Core' => 'Core/',
];

foreach($to_map as $prefix => $base_dir)
{
    spl_autoload_register(function ($class) use ($prefix, $base_dir) {

        $base_dir = __DIR__ . "/{$base_dir}";

        $len = strlen($prefix);
        if (strncmp($prefix, $class, $len) !== 0)
        {
            return;
        }

        $relative_class = substr($class, $len);

        $file = $base_dir . str_replace('', '/', $relative_class) . '.php';

        if (file_exists($file))
        {
            require $file;
        }
    });
}
Comment

PREVIOUS NEXT
Code Example
Php :: php datetime from timestamp 
Php :: wordpress remove taxonomy from post 
Php :: laravel select raw where 
Php :: drupal 7 hook_node_update 
Php :: category title in post 
Php :: php unique associative array by value 
Php :: carbon between hours 
Php :: laravel count distance lat/longtidue 
Php :: laravel update query builder 
Php :: laravel Impossible to create the root directory 
Php :: trait php 
Php :: wp add menu page and subpage 
Php :: wp php category page count products 
Php :: how to get meta information from pagination in laravel controller 
Php :: artisan in route in laravel 
Php :: add another column in a table in laravel 
Php :: php null 
Php :: php build query from array 
Php :: php get slug 
Php :: echo in console command laravel 
Php :: php self referencing form 
Php :: how to include javascript in php 
Php :: ?? php 
Php :: php class file upload 
Php :: laravel inline if else if 
Php :: violation: 1071 Specified key was too long; max key length is 1000 bytes 
Php :: filter wordpress 
Php :: laravel redis cache 
Php :: laravel default encryption mode 
Php :: json_encode php 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =