定制 escribiendocodigo/phalcon-react-project-skeleton 二次开发

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

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

escribiendocodigo/phalcon-react-project-skeleton

最新稳定版本:v5.0.0

Composer 安装命令:

composer create-project escribiendocodigo/phalcon-react-project-skeleton

包简介

Phalcon React project skeleton

README 文档

README

Skeleton application using Phalcon framework and Vite + React.

Requirements

  • PHP >= 7.4.1
  • Phalcon >= 5.0.0
  • Node >= 18.0.0

Structure

my-project/
  ¦
  ├-- backend/
  ¦
  └-- frontend/

Backend

Phalcon micro application that provides a RESTful API running port 8000

Frontend

Vite + React application running port 5173

Proxying to a backend

http://localhost:5173/api -> http://localhost:8000

// vite.config.js

import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";

const BACKEND_PORT = process.env.BACKEND_PORT || 8000;

export default defineConfig({
  plugins: [react()],
  server: {
    host: "0.0.0.0",
    proxy: {
      "/api": {
        target: `http://127.0.0.1:${BACKEND_PORT}`,
        // changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ""),
      },
    },
  },
});

Installing via Composer

composer create-project escribiendocodigo/phalcon-react-project-skeleton my-project

Once installed, you can test it out immediately using PHP's built-in web server:

cd my-project

Run backend

cd backend
composer serve
# OR use the composer alias:
composer serve-backend

Run frontend

cd frontend
npm run dev
# OR use the composer alias:
composer serve-frontend

Build frontend

cd frontend
npm run build
# OR use the composer alias:
composer build-frontend

Web server setup

Nginx

server {
    listen 80;
    server_name my-domain www.my-domain;

    index index.html index.php;

    access_log /var/log/nginx/my-domain.access.log;
    error_log /var/log/nginx/my-domain.error.log;

    location / {
        root /var/www/my-project/frontend/dist;

        try_files $uri $uri/ /index.html;
    }

    location /api {
        rewrite ^/api(.*)$ /index.php;
        set $request_url $1;
    }

    location ~ \.php$ {
        root /var/www/my-project/backend/public;

        include /etc/nginx/snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
        fastcgi_param REQUEST_URI $request_url;
    }

    location ~ /\.ht {
        deny all;
    }

}

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: JavaScript

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-08-09