Skip to content
This repository was archived by the owner on Jul 31, 2026. It is now read-only.

Latest commit

 

History

22 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

one-php-mvc

one-php-mvc is a true PHP micro-framework that is contained in one PHP file with internationalization support. No libraries, extensions or dependencies.

It has everything you need to write an MVC application in PHP and nothing you don't need. Since one-php-mvc contains only one file to initialize and execute server requests, it contains no autoloader, no ORM/DCI, and no additional packages or frameworks. Controllers and View pages are dynamically loaded based on the requested URL. Developers interested in using one-php-mvc can add anything else they need.

Because the one-php-mvc micro framework exists in one PHP file and only loads the files required to complete the request, this makes one-php-mvc faster than other PHP micro-frameworks and certainly faster than other larger PHP frameworks with built in functionalities. The application is also highly portable. Compatible with PHP 5.3 and up, one-php-mvc will run on almost any machine with any PHP configuration.

What Files are Included?

index.php

What Other Files are Included?

Optionally, the user can can create a configuration file which is expected to contain a JSON object. When the Router is constructed, the user can pass in the file path for this configuration object, and it's properties will be added to the Configuration class.

This repository also contains sample projects for setting up one-php-mvc for a variety of uses.

Why one-php-mvc?

  • Lightweight - Because it's one file.
  • Fast - Because it loads only one file.
  • Customizable - Because it's one file, there is so much room for more.
  • Flexible - Because it's written in PHP, and it's only one file.

How Should I Structure My Project?

  • /controllers
    • home.php
  • /includes
  • /lang
  • /views
    • /home
      • index.php
    • _layout.php
  • config.json
  • index.php

How Do I Setup My Webserver?

Same way as other PHP MVC frameworks:

Apache

In your site-configuration file add the following:

<Directory />
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule .* index.php [QSA,L]
</Directory>

IIS

In the Web.config add the following:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <directoryBrowse enabled="false" />
        <rewrite>
            <rules>
                <rule name="Rewrite Rule" stopProcessing="true">
                    <match url="^(.*)$" ignoreCase="true" />
                    <conditions>
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php" appendQueryString="true" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

Internationalization / Localization

For applications requiring language specific pages, language files for each supported language can be created. For example, create the following file:

  • /lang/en.json

    {
    "title": "one-php-mvc",
    "tag_line": "Most Fastest-Bestest PHP Micro-Framework"
    }

Now in your view you can specify:

<h1><?php echo $this->get_lang('title'); ?></h1>
<p><?php echo $this->get_lang('tag_line'); ?></p>

For additional languages, simply add the language file to the /lang directory, e.g. /lang/fr.json and add the text fr to the languages array in the configuration. When using links, route the URL with the Controller's route_url function and the language will automatically be pre-pended to the URL.

About

one-php-mvc is a true PHP micro-framework that is contained in one PHP file with localization support. No libraries, extensions or dependencies.

Resources

Stars

17 stars

Watchers

4 watching

Forks

Releases

Packages

Contributors

Languages