承接 jadempinky/pinkyflow 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

jadempinky/pinkyflow

Composer 安装命令:

composer require jadempinky/pinkyflow

包简介

A PHP framework that makes your code flow like water. PinkyFlow provides essential modules like user management, shopping cart, and commenting, while maintaining flexibility for custom extensions.

README 文档

README

PinkyFlow is a simple and modular PHP framework designed for tasks like user management, shopping carts, comments, and more. It handles autoloading, database interactions, and module initialization, allowing you to focus on building your application.

Getting Started

1. Install via Composer

To install PinkyFlow in your project, use Composer:

composer require jadempinky/pinkyflow

2. Configuring the Framework

PinkyFlow uses a config/config.php file for configuration. Edit the values to your needs.

<?php

namespace PinkyFlow;

class Config {
    public static $enableDatabase = true;
    public static $enableUserModule = true;
    public static $enableShoppingModule = true;
    public static $enableCommentModule = true;

    public static $dbHost = 'localhost';  // Database host
    public static $dbUser = 'root';       // Database username
    public static $dbPass = '';           // Database password
    public static $dbName = 'pinkyflow';  // Database name
}

3. Example: User Registration and Login

The following code demonstrates how to use PinkyFlow for user registration, login, and retrieving user details:

Index :

<?php
require_once __DIR__ . '/vendor/jadempinky/pinkyflow/PinkyFlow.php';
?>

ProfileController :

<?php

class ProfileController {
    private $user;
    private $basepathforcss;

    public function __construct($user, $basepathforcss) {
        $this->user = $user;
        $this->basepathforcss = $basepathforcss;
    }

    public function handleProfile() {
        if (!$this->user->isLoggedIn()) {
            header("Location: {$this->basepathforcss}/login");
            exit;
        }

        if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['profile_picture'])) {
            $this->user->handleProfilePicture($_FILES['profile_picture']);
        }

        // Handle logout
        if ($user->isLoggedIn()) {
            echo '<form action="' . $_SERVER['PHP_SELF'] . '" method="post"><button type="submit" name="logout">Logout</button></form>';
        }

        if (isset($_POST['logout'])) {
            $user->logout();
        }
    }
}

$profile = new ProfileController($user, $basepathforcss);
$profile->handleProfile();

?>

Profile view :

<?php


    <div class="profile-container">
        <div class="profile-header">
            <img src="<?php echo $user->getProfilePicture(); ?>" alt="<?php echo $user->getUsername(); ?>'s Profile Picture" onclick="showfileinput()">
            <h1>Profile</h1>
            <form method="post" enctype="multipart/form-data">
                <input type="file" id="fileinput" name="profile_picture" accept="image/*" style="display: none;" onchange="this.form.submit()">
            </form>
        </div>
        <ul class="profile-details">
            <li><span>Username:</span> <?php echo $user->getUsername(); ?></li>
            <li><span>Email:</span> <?php echo $user->getEmail(); ?></li>
            <li><span>Role:</span> <?php echo $user->getRole(); ?></li>
        </ul>
        <p><a href="<?php echo $basepathforcss ?>/logout">Logout</a></p>
    </div>

    <script>
        function showfileinput() {
            document.getElementById('fileinput').click();
        }
    </script>

?>

Login-Register system

// Handle register / login
if (!$user->isLoggedIn()) {
    if (isset($_POST['register'])) {
        $user->register($_POST['username'], $_POST['password'], $_POST['password'], $_POST['email']);
    }
    if (isset($_POST['login'])) {
        $user->login($_POST['username'], $_POST['password']);
    }
}
        
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
    <input type="text" name="username" placeholder="Username"><br>
    <input type="password" name="password" placeholder="Password"><br>
    <input type="email" name="email" placeholder="Email"><br>
    <button type="submit" name="register">Register</button>
</form>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
    <input type="text" name="username" placeholder="Username"><br>
    <input type="password" name="password" placeholder="Password"><br>
    <button type="submit" name="login">Login</button>
</form>

Running Your Code

To see your code in action, you can use local development environments like Laragon, XAMPP, or WAMP. These applications provide an easy way to set up a local web server and database on your machine.

Using Laragon

  1. Download and install Laragon.
  2. Place your project files in the Laragon's www directory (usually C:\laragon\www\).
  3. Start Laragon and click the "Start All" button.
  4. Open your web browser and navigate to http://localhost/your-project-folder.

Using XAMPP or WAMP

  1. Download and install XAMPP or WAMP.
  2. Place your project files in the htdocs (XAMPP) or www (WAMP) directory.
  3. Start Apache and MySQL services from the control panel.
  4. Open your web browser and navigate to http://localhost/your-project-folder.

Remember to configure your database settings in the Config class to match your local environment.

By using these tools, you can easily test and debug your PinkyFlow application on your local machine before deploying it to a live server.

Key Features

  • Automatic Database Handling: PinkyFlow creates the database and necessary tables automatically.
  • Autoloading: Classes and modules are loaded automatically. No need for manual use statements.
  • User Management: Easily handle user registration, login, and details retrieval with minimal code.
  • Shopping Cart: Implement shopping cart functionality with ease.
  • Comment System: Add and manage comments in your application.
  • New Modules coming soon:

License

PinkyFlow is open-source and licensed under the MIT License.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-10-17