定制 lracdim/callie-php 二次开发

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

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

lracdim/callie-php

最新稳定版本:v1.0.0

Composer 安装命令:

composer create-project lracdim/callie-php

包简介

A zero-dependency, upload-and-run PHP micro-framework for building REST APIs. Perfect for shared hosting.

README 文档

README

A zero-dependency, upload-and-run PHP micro-framework for building REST APIs.

Perfect for shared hosting, cPanel, XAMPP, or any server with PHP 7.4+.

✨ Features

  • Zero Dependencies - No Composer required, just download and run
  • Express-style Routing - $app->get(), $app->post(), etc.
  • Built-in Query Builder - Secure MySQL operations with PDO
  • JWT Authentication - Built-in token generation and verification
  • CORS Ready - Pre-configured for frontend integration

📦 Installation

Option 1: Download ZIP (Recommended)

  1. Download the latest release
  2. Extract to your server folder
  3. Configure .env with your database credentials
  4. Done! Visit http://localhost/your-folder

Option 2: Via Composer

composer create-project lracdim/callie-php my-app --stability=dev

🚀 Quick Start

1. Configure Database

Copy .env.example to .env and update your credentials:

DB_HOST=127.0.0.1
DB_NAME=your_database
DB_USER=root
DB_PASSWORD=your_password

2. Create Your First Route

Edit routes.php:

$app->get('/api/hello', function($ctx) {
    $ctx->success(['message' => 'Hello, World!']);
});

$app->get('/api/users', function($ctx) {
    $users = Database::getInstance()->table('users')->get();
    $ctx->success($users);
});

$app->post('/api/users', function($ctx) {
    $id = Database::getInstance()->table('users')->insert($ctx->body);
    $ctx->success(['id' => $id], 'User created', 201);
});

3. Test It

curl http://localhost/your-folder/api/hello

📁 Project Structure

├── core/           # Framework internals (don't edit)
│   ├── Callie.php
│   ├── Router.php
│   ├── Database.php
│   └── Security.php
├── .env            # Your credentials (never commit!)
├── .env.example    # Template for .env
├── .htaccess       # Apache routing rules
├── index.php       # Entry point
├── routes.php      # YOUR API LOGIC GOES HERE
└── schema.sql      # Database schema template

🔐 Authentication

// Login - Generate Token
$app->post('/auth/login', function($ctx) {
    $user = Database::getInstance()
        ->table('users')
        ->where('email', $ctx->body['email'])
        ->first();
    
    if (!$user || !Security::verifyPassword($ctx->body['password'], $user['password'])) {
        return $ctx->error('Invalid credentials', 401);
    }
    
    $token = Security::generateToken(['id' => $user['id'], 'role' => $user['role']]);
    $ctx->success(['token' => $token]);
});

// Protected Route
$app->get('/api/profile', function($ctx) {
    $user = Security::auth(); // Returns 401 if invalid
    $ctx->success($user);
});

📋 Requirements

  • PHP 7.4 or higher
  • PDO extension (enabled by default)
  • MySQL 5.7+ or MariaDB 10.2+

📄 License

MIT License - Use it however you want!

Made with ❤️ for developers who just want to ship.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-12-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固