PHPackages                             molajo/resource - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. molajo/resource

ActiveMolajo-package[Utility &amp; Helpers](/categories/utility)

molajo/resource
===============

Molajo Resource Services for PHP Applications

v0.1(12y ago)01.3k[1 PRs](https://github.com/Molajo/Resource/pulls)MITPHPPHP &gt;=5.3.3

Since Nov 23Pushed 10y ago5 watchersCompare

[ Source](https://github.com/Molajo/Resource)[ Packagist](https://packagist.org/packages/molajo/resource)[ Docs](http://github.com/Molajo/Loader)[ RSS](/packages/molajo-resource/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (1)DependenciesVersions (5)Used By (0)

======= Resource
================

[](#resource)

[![Build Status](https://camo.githubusercontent.com/d50cf097287f1390a55f7d135634bf79cc9e34993206d6764701b2332f5e7778/68747470733a2f2f7472617669732d63692e6f72672f4d6f6c616a6f2f5265736f757263652e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/Molajo/Resource)

*Resource* provides PHP applications with a generalized approach for locating and handling file and folder resource using URI namespaces.

Basic Principles
----------------

[](#basic-principles)

With *Resource*, applications interact with filesystem resource using a URI namespace, rather than specifying file and folder names.

This approach provides two important benefits:

First, namespacing generalizes location information so that the application no longer requires hardcoded physical locations. The *Resource* package locates the physical location based on the URI namespace resulting in flexibility as to storage location and facility.

Second, the *Resource* package uses an adapter handler to process process the application request for the resource. In this sense, the treatment required for each file request can be customized based on the URI scheme. For example, the handler for PHP classes can defined as an SPL autoloader while the handler for an XML configuration file might return an XML string read from the located file. In the case of a model, one might return a Read Controller, instantiated with all dependencies injected and ready for queries. A request for an image file might return an image, resized, as needed. The possibilities are endless.

Examples of how Molajo uses Resource
------------------------------------

[](#examples-of-how-molajo-uses-resource)

### Class Handler

[](#class-handler)

The *Resource* Class Handler is defined as an `SPL Autoloader`. PHP passes any requests to locate a class file to this method which attempts to locate the file and includes it, if found.

### XML Handler

[](#xml-handler)

The *Resource* XML Handler locates and returns the path for a specified resource

```
