Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php using composer autoload - own code

{
    "autoload": {
        "psr-4": {"Acme": "src/"}
    }
}
Comment

custom autoload without composer

<?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

composer autoload

require __DIR__ . '/vendor/autoload.php';

$log = new MonologLogger('name');
$log->pushHandler(new MonologHandlerStreamHandler('app.log', MonologLogger::WARNING));
$log->addWarning('Foo');
Comment

PREVIOUS NEXT
Code Example
Php :: config clear without artisan 
Php :: How to Connect MySQL Database with PHP Websites 
Php :: select option in laravel 
Php :: generate unique order id in php 
Php :: copy php array to another 
Php :: php unique assoc array by value 
Php :: define constructor in trait php 
Php :: php add array to array 
Php :: laravel cors enable 
Php :: login selected user laravel 
Php :: add-basic-controller-imports 
Php :: check the route type in laravel 
Php :: german locale php 
Php :: blank admin page magento 2.3 
Php :: laravel middleware in constructor 
Php :: set only allow post request to a page - php 
Php :: php super global variables 
Php :: Uncaught ReferenceError: commonL10n is not defined 
Php :: eager load relationships by default in the model laravel 
Php :: laravel list of models 
Php :: laravel get view variables 
Php :: get request header codeingiter3 
Php :: php array differ 
Php :: how to add column to database in laravel 
Php :: run laravel seeder 
Php :: clear cache in laravel without artisan 
Php :: php header not working 
Php :: php multiplication 
Php :: ajax search request 
Php :: laravel access storage attachment 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =