定制 prophp/bin-php 二次开发

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

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

prophp/bin-php

最新稳定版本:v1.0.0

Composer 安装命令:

composer require prophp/bin-php

包简介

README 文档

README

README

◦ Requirements for the usage

  • PHP 8.0+
  • Composer
  • Linux (Docker daemon might be used on any OS: Windows & macOS)

◦ Requirements for the package development

Recommended package for setting up a docker container: prophp/docker-bridge (docker-compose is required)

◦ Install

composer require prophp/bin-php --dev

▸ Initialize bin/_php directory

vendor/bin/php init

OPTIONAL

Rename bin/_php/config/var-www-html.dist.txt to bin/_php/config/var-www-html.txt (Remove .dist)

Put your project directory's absolute path there, do not forget to put / at the end

This config file will replace the substring /var/www/html/ (path in docker image) with its contents when displaying an executed PHP file's absolute path

▸ Build a symlink bin/example for the file bin/_php/src/example.php

vendor/bin/php sym

Now you are ready to use bin/example executable SYMLINK, try it:

bin/example

Expected output:

Executing PHP file://<bin/_php/config/var-www-html.txt contents>bin/_php/src/example.php
Hello world!

▸ Build a php execution file bin/_php/execute-all.php

vendor/bin/php exec

Now you can use it in order to execute all files in bin/_php/src/ directory. Useful for Gitlab CI

php bin/_php/execute-all.php

Expected output:

Executing PHP file://<bin/_php/config/var-www-html.txt contents>bin/_php/src/example.php
Hello world!

▸ GIT commit bin directory excluding bin/_php/config one

.gitignore

/bin/_php/config/*

bin/example && php bin/_php/execute-all.php will be working even if prophp/bin-php package is removed from Composer (vendor dir)

You may try it by using this composer command:

composer remove prophp/bin-php --dev

Do not forget to install it afterwards for using its DEV tools

◦ Usage

▸ Create a new PHP file that you want to execute using bin/<symlink>

You may create any .php files and subdirectories for them inside bin/_php/src directory

Take a look at /bin/_php/src/example.php

▸ Rebuild symlinks for all .php files inside bin/_php/src directory

vendor/bin/php sym

▸ Rebuild a bin/_php/execute-all.php file that will execute all .php files inside bin/_php/src/ directory

vendor/bin/php exec

◦ Usage example

▸ Create a new PHP file that you want to execute using bin/<symlink>

Create a bin/_php/src/create/products.php file

#!/usr/bin/env php
<?php

require_once dirname(__DIR__, 4) . "/vendor/autoload.php";

echo "Create products!" . PHP_EOL;

▸ Rebuild symlinks

vendor/bin/php sym

▸ Use the freshly generated symbolic link. You are free to use autosuggestions pressing Tab button

bin/create/products

▸ Rebuild a file that executes all your .php files inside bin/_php/src

vendor/bin/php exec

Try it:

php bin/_php/execute-all.php

Expected output:

Executing PHP file://<bin/_php/config/var-www-html.txt contents>bin/_php/src/example.php
Hello world!

Executing PHP file://<bin/_php/config/var-www-html.txt contents>bin/_php/src/create/products.php
Create products!

◦ GitLab CI

When using a GitLab CI, you need to execute PHP files directly as GitLab CI has problems with SYMLINKS (at the moment)

If you use SYMLINKS, GitLab CI will execute them properly but will not mark tests as FAILED even if your .php file throws an Exception. (Tests will always succeed)

You have to use php for proper results!

You may specify certain scripts manually

.gitlab-ci.yml

test:8.0:
  script:
    - exec "php bin/_php/src/example.php"
    - exec "php bin/_php/src/create/products.php"

or use a freshly generated bin/_php/execute-all.php file to execute them all at once

.gitlab-ci.yml

test:8.0:
  script:
    - exec "php bin/_php/execute-all.php"

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-02-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固