Oroboros Core
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo

Namespaces

  • None
  • oroboros
    • core
      • abstracts
        • adapters
        • bootstrap
        • controllers
        • libraries
          • auth
          • bootstrap
          • cache
          • codex
          • config
          • container
          • data
          • database
          • dns
          • entity
          • enum
          • error
          • event
          • extension
          • file
          • flags
          • hooks
          • job
          • logger
          • manager
          • message
          • prototype
          • request
          • response
          • routine
          • shell
          • startup
          • stream
          • template
          • uri
          • utility
          • validation
            • workers
          • worker
        • models
        • patterns
          • behavioral
          • creational
        • utilities
          • exception
            • cache
            • container
          • http
        • views
      • interfaces
        • adapters
          • interpreters
          • sdk
        • api
          • adapters
          • bootstrap
          • controllers
          • psr
        • contract
          • adapters
          • bootstrap
          • codex
          • components
          • controllers
          • data
          • entities
          • errors
          • events
          • extensions
          • jobs
          • libraries
            • auth
            • cache
            • config
            • container
            • enum
            • file
            • flags
            • hooks
            • module
            • promise
            • record
            • request
            • response
            • server
            • shutdown
            • site
            • stream
            • template
            • theme
            • uri
          • models
          • patterns
            • behavioral
            • concurrency
            • creational
            • structural
          • routes
          • routines
            • bootload
            • declarative
            • procedural
            • subsystem
          • services
            • consumer
              • cgi
              • rest
                • local
                • remote
                  • authenticated
                  • unauthenticated
            • provider
              • cgi
              • rest
                • local
                • remote
                  • authenticated
                  • unauthenticated
          • utilities
            • datetime
            • exception
              • cache
              • container
            • filebase
            • http
            • math
            • parser
            • regex
            • session
          • views
        • enumerated
          • environment
          • flags
          • http
          • views
        • libraries
          • manager
          • worker
      • libraries
        • api
        • codex
        • container
        • enum
          • http
        • file
        • hooks
        • logger
        • math
        • psr4
        • request
        • response
        • stream
        • uri
      • patterns
        • creational
      • traits
        • adapters
        • bootstrap
        • codex
        • components
        • controllers
        • data
        • entities
        • events
        • extensions
        • jobs
        • libraries
          • container
          • file
          • request
          • response
          • stream
          • uri
        • models
        • modules
        • patterns
          • behavioral
          • concurrency
          • creational
          • structural
        • routes
        • services
        • utilities
          • core
            • api
            • config
            • contract
              • contract
            • enum
            • environment
            • routines
          • datetime
          • error
          • exception
          • filebase
          • hooks
          • html
          • http
          • logic
          • math
          • parsers
          • regex
          • session
        • views
      • utilities
        • exception
          • cache
          • container
        • http
      • views
    • tests
      • patterns
        • creational
      • psr
        • psr7
      • utilities
        • exception
  • PasswordCompat
    • binary
  • PHP

Classes

  • Autoloader

Class Autoloader

An example of a general-purpose implementation that includes the optional functionality of allowing multiple base directories for a single namespace prefix.

Given a foo-bar package of classes in the file system at the following paths ... /path/to/packages/foo-bar/ src/ Baz.php # Foo\Bar\Baz Qux/ Quux.php # Foo\Bar\Qux\Quux tests/ BazTest.php # Foo\Bar\BazTest Qux/ QuuxTest.php # Foo\Bar\Qux\QuuxTest

... add the path to the class files for the \Foo\Bar\ namespace prefix as follows: <?php // instantiate the loader $loader = new \Example\Psr4AutoloaderClass; // register the autoloader $loader->register(); // register the base directories for the namespace prefix $loader->addNamespace('Foo\Bar', '/path/to/packages/foo-bar/src'); $loader->addNamespace('Foo\Bar', '/path/to/packages/foo-bar/tests');

The following line would cause the autoloader to attempt to load the \Foo\Bar\Qux\Quux class from /path/to/packages/foo-bar/src/Qux/Quux.php: <?php new \Foo\Bar\Qux\Quux;

The following line would cause the autoloader to attempt to load the \Foo\Bar\Qux\QuuxTest class from /path/to/packages/foo-bar/tests/Qux/QuuxTest.php: <?php new \Foo\Bar\Qux\QuuxTest;

Namespace: oroboros\core\libraries\psr4
Located at core/libraries/psr4/Autoloader.php

Methods summary

public
# register( )

Register loader with SPL autoloader stack.

Register loader with SPL autoloader stack.

public
# addNamespace( string $prefix, string $base_dir, boolean $prepend = false )

Adds a base directory for a namespace prefix.

Adds a base directory for a namespace prefix.

Parameters

$prefix
The namespace prefix.
$base_dir

A base directory for class files in the namespace.

$prepend

If true, prepend the base directory to the stack instead of appending it; this causes it to be searched first rather than last.

public mixed
# loadClass( string $class )

Loads the class file for a given class name.

Loads the class file for a given class name.

Parameters

$class
The fully-qualified class name.

Returns

mixed

The mapped file name on success, or boolean false on failure.

protected mixed
# loadMappedFile( string $prefix, string $relative_class )

Load the mapped file for a namespace prefix and relative class.

Load the mapped file for a namespace prefix and relative class.

Parameters

$prefix
The namespace prefix.
$relative_class
The relative class name.

Returns

mixed

Boolean false if no mapped file can be loaded, or the name of the mapped file that was loaded.

protected boolean
# requireFile( string $file )

If a file exists, require it from the file system.

If a file exists, require it from the file system.

Parameters

$file
The file to require.

Returns

boolean
True if the file exists, false if not.

Properties summary

protected array $prefixes

An associative array where the key is a namespace prefix and the value is an array of base directories for classes in that namespace.

An associative array where the key is a namespace prefix and the value is an array of base directories for classes in that namespace.

# array()
Oroboros Core API documentation generated by ApiGen