languaojs/viperphp

A PHP Framework

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

Type:project

pkg:composer/languaojs/viperphp

v0.1.4 2026-01-13 07:36 UTC

This package is auto-updated.

Last update: 2026-01-13 07:42:36 UTC


README

ViperPHP is a lightweight, easy-to-use, and secure PHP framework designed for rapid development. It features a clean structure, a built-in CLI tool, and a flexible asset management system.

🚀 Installation

Install ViperPHP using Composer:

composer create-project languaojs/viperphp your-app-name

This should be followed by:

composer update

And

composer dump-autoload

Then, go to config/Config.php and set your base URL (e.g., http://localhost/your-app-name). Run XAMPP or WAMP, the go to your app URL.

🛠 Getting Started

1. The Home Page

To edit the main landing page, go to:

app/Views/home/index.php

2. The Navigation Menu

To edit the global navbar, go to:

app/Views/partials/home-menu.php

3. Configuration

To set your App Name, Security Keys, or Database Credentials, open:

config/Config.php

📄 Creating a New Page

To create a new page (e.g., About), follow these steps:

1. Create a Controller:

Open your terminal and type:

php craft make:controller About

Alternatively, manually create app/Controllers/About.php.

2. Set up the logic

Inside your new controller, ensure you have an index() method. You can copy the structure from Home.php.

3. Create the view

  • Create a folder: app/Views/about/
  • Create a file: app/Views/about/index.php

4. Connect Controller to a view

In your About.php controller, update the view call:

$this->view('about/index');

🎨 Asset Management (CSS & JS)

ViperPHP uses a unique method to register and load assets, allowing you to load only what you need per page.

Registering Assets

Go to app/Libraries/Assets.php to register your files. You can use local files or CDN links:

  • Place local files in public/assets/css/ or public/assets/js/.
  • Register them in the Assets.php library.
  • Set Default Assets in this file to load them on every page automatically.

Loading Assets in the Controller

You can determine which assets load for a specific method directly in the controller.

🖼 Media & Images

All images and media files should be placed in public/media/.

Retrieving Media

Use the get_media($path) helper function to generate the correct URL. This function supports subfolders and filenames. Example Usage:

<!-- To get an image named code2.png -->
<img src="<?= get_media('code2.png'); ?>" alt="My Image">

How to set assets in the controller

Classes and Files naming conventions

As usual, the class name and the file name must be identical. So, if the class is Home_model, the file name must be Home_model.php. This also applies to the Controllers. For instance, the Controller class User must have the file name User.php. For Controllers and Models, avoid using PascalCase, though it is typical. If you want to use PascalCase, you can modify the Router and Controller classes, which are located in the system directory.

Classes in the Libraries directory, both in the system and app directories, can use PascalCase.

The methods and functions can be written using PascalCase() or underscored_pattern().