定制 languaojs/viperphp 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

languaojs/viperphp

最新稳定版本:v0.1.4

Composer 安装命令:

composer create-project languaojs/viperphp

包简介

A PHP Framework

README 文档

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().

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固