Download the PHP package jacob-roth/simple-framework without Composer
On this page you can find all versions of the php package jacob-roth/simple-framework. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jacob-roth/simple-framework
More information about jacob-roth/simple-framework
Files in jacob-roth/simple-framework
Package simple-framework
Short Description SimpleFramework is a simple framework for building out html\php pages
License MIT
Homepage https://github.com/JacobRothDevelopment/Phapi
Informations about the package simple-framework
SimpleFramework
SimpleFramework is a simple framework for building out php pages
So J, what does this do?
Ever want to build a static website and want to reuse code you made? No? What do you mean no one builds static sites anymore? Well, SimpleFramework lets you do this anyway.
What's that? Other packages do this better? That's probably true. You should use them, then.
What SimpleFramework does:
- URL Routing
- maps requests to
pagesdirectory - ex: requesting
/page1delivers/pages/page1.php - ex: requesting
/creative/page1delivers/pages/creative/page1.php - still works for assets
- ex: requesting
/assets/styles.cssdelivers/assets/styles.css
- maps requests to
- Build Pages
- PHP pages in the
pagesdirectory - Use Components
- PHP pages in the
- Build Components
- PHP or HTML files in the
componentsdirectory - Components can be reused between pages
- Can pass parameters through
$dataobject to and between components
- PHP or HTML files in the
What You Need To Do
-
composer require jacob-roth/simple-framework -
Create
/pagesand/componentsdirectories in project root -
Add the following to
.htaccessinto project root directory -
Create
index.phpin project root directory - Add the following to
index.php
Using Util
| Util function | Description |
|---|---|
| includeComponent | Import Component |
| requireComponent | Import Component Throws error if file doesn't exist |
| loadContent | Start processing the url request |
| loadResource | Load only given resource file (ie stylesheet, image, etc.) |
ENVs
If needed, you can change some of the defaults in SimpleFramework using $_ENV
| $_ENV name | Default | Description |
|---|---|---|
| APP_SF_COMPONENTS | components |
Directory where component files are located |
| APP_SF_PAGES | pages |
Directory where pages are located |
| APP_SF_ROOT | index.php |
Root PHP page name |
| APP_SF_404 | null |
The page delivered when url doesn't map to file |
| APP_SF_IGNORE_REGEX | ["/^\/\..*$/","/^\/vendor$/"] |
If any requests match any of the regular expressions, automatically return 404 |
| APP_SF_APACHE_MIME_DOT_TYPES | /etc/mime.types |
The file path for apache mime types |
| APP_SF_MIME_TYPES_MAP | null |
Map of file extensions to content types |
You can set these ENVs like this:
This must be done after calling Constants::setDefaults()
Limitations
- If you choose to change the ENV variable
APP_SF_APACHE_MIME_DOT_TYPES, you must run the following to properly create the type mapping