Download the PHP package richie314/simple-mvc without Composer

On this page you can find all versions of the php package richie314/simple-mvc. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package simple-mvc

A minimal Model-View-Control library for PHP

Packagist version Latest GitHub release Docker test status Test and release workflow status

A small PHP MVC library with explicit routes, controllers, PHP views, action attributes, and utility helpers.

Webserver setup

Installation

The library requires PHP 8.3 or newer, including sensitive-parameter redaction for password arguments. The optional database integration uses mysqli; MIME detection uses fileinfo.

Quick start

Create this directory structure:

Visit /?name=Ada for HTML or /hello?first-name=Ada for JSON. GET query strings and POST form fields become named action arguments; hyphens in field names become underscores. Match action parameter names to submitted fields and provide defaults for optional values. Other request methods do not automatically bind bodies or query strings. Actions must return a StatusCode or a supported integer status.

AddController() registers public methods except names starting with _ or #, plus the base route mapped to index. Keep helpers protected or private. To expose only specific actions, register explicit routes instead:

For installation under /myapp, pass pathPrefix: '/myapp' to Router and keep route names relative to that prefix (for example /welcome). $P is available to layouts and views for generating links. Routes use exact paths; trailing slashes are significant.

Controller responses

These calls belong inside controller actions:

JsonWithOptions() and RedirectWithStatus() are optional helpers; existing Json() and Redirect() signatures remain unchanged. Redirect() retains its legacy behavior: it returns MovedPermanently (301), while PHP normally sends 302 for the Location header. Use RedirectWithStatus() when the returned and emitted status must agree.

JSON encoding failures now throw JsonException, which dispatch handles as a server error when headers have not been sent. Successful content and view responses explicitly set their status, including 200.

Views resolve beneath Views/, then Views/Shared/, with .php, .html, and .htm extensions tried for names without a dot. Render() accepts the existing cutomLayout named parameter (spelling preserved) for an alternative layout path. View data and default variables are available in both layout and body. Default variables take precedence over action data; built-in variables $title, $status_code, $user, $P, and $RenderBody take precedence over both. Internal rendering variables are reserved. Escape untrusted output with htmlspecialchars().

Provide Views/Shared/Error.php to customize errors using $main_banner (and $exception for server errors). Without it, error helpers return plain text with the appropriate status. Exceptions after headers are sent are rethrown. Keep exception details out of public error templates and configure production error handling appropriately.

Authentication and database integration

Load your application user and connection before dispatch:

Protect an action with the built-in attribute:

Use requireAdmin: true to additionally require $user->Admin. Missing users are redirected to login and the original request is stored in the Redirect cookie. Authentication enforcement terminates the request. Your app supplies login and user persistence.

Utilities

SetWithOptions() and DeleteWithOptions() preserve existing cookie method signatures, including subclass overrides. Cookie security options are opt-in: existing calls retain secure: false, httpOnly: true, and no SameSite setting. Cookies must be written before response output. Cookie reads reflect the incoming request, not cookies just written to response headers.

Security::GetIpAddress() retains its existing proxy-header precedence. Enable allowCloudlfare: true only behind a trusted Cloudflare proxy. Forwarded headers must be sanitized by your infrastructure before using these addresses for access control.

Webserver configuration

Apache

Enable mod_rewrite and allow overrides for the application directory. Place this .htaccess beside index.php:

Expose only the front controller and intended public assets; deny direct access to application code, views, vendor files, and configuration in your server configuration.

Nginx

In this example the nginx server listens on port 8080 and redirectes all the traffic to index.php, except for the Public folder, where is assumed there are public static files that will be served without redirecting the request to the index.php file first.

In the configuration below, php is accessed via a unix socket.


All versions of simple-mvc with dependencies

PHP Build Version
Package Version
Requires php Version >=8.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package richie314/simple-mvc contains the following files

Loading the files please wait ...