承接 3bg-supply-co/php-functions 相关项目开发

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

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

3bg-supply-co/php-functions

Composer 安装命令:

composer require 3bg-supply-co/php-functions

包简介

This package contains random functions and classes that can be reused in any PHP project.

README 文档

README

This package is a collection of reusable classes and functions that are currently being used in many of our projects.

Table of Contents

  1. Requirements
  2. Installation
  3. Usage

Requirements

In order to use this package, the following requirements must be met:

  • credentials.ini file must exist 2 levels above the root directory
    • For example: if the code is deployed to the following directory: /var/www/html/test/, then the file would have to be located in the following directory: /var/www/credentials/credentials.ini.
  • Composer
  • PHP version 7.0+
  • SSH Access
    • Follow this tutorial to set up the SSH Key
    • You can test it by running the following command on the machine with the SSH Key: ssh -T git@github.com

Installation

To install this package, the following steps must be followed (in order):

  • Create a composer.json file in your project by running the following command: composer init
  • After going through the options, add the following code to the composer.json file:
    "minimum-stability": "dev",
    "require": {
      "3bg-supply-co/php-functions": "^1.6"
    }
  • Run composer update -n

Usage

To use this collection of code, determine what your need is. All classes found in this package will use the base namespace Common3BG.

To use the logging function writeLog(), the /tmp/ directory must have write permissions by the user executing the script.

For example, if all you need is access to the functions found in the src/GenericFunctions.php file, then just call said function in your script.

If you need to use one of the classes (such as ApiResponse), then you must include the proper namespace. For example, the following line of code is needed to use the ApiResponse class:

  use Common3BG\ApiResponse as ApiResponse;

ApiResponse Class

This class takes no parameters.

The following method

Sample PHP Code
require (__DIR__) . '/vendor/autoload.php';
use Common3BG\ApiResponse as ApiResponse;

$apiResponse = new ApiResponse();

// Sample #1: simple one liner being added to message then returning the response
$apiResponse->addMessage('Testing a custom message');
$apiResponse->sendResponse();

// Sample #2: adding another message then returning the response
$apiResponse->addMessage('Testing a second custom message');
$apiResponse->sendResponse();

// Sample #3: sending a fail response without any parameters
$apiResponse->sendFailResponse();


// Sample #4: adding a string error message with no data, then returning the fail response
$apiResponse->sendFailResponse('Custom Error Message with no $data given');

// Sample $5: adding an error message with data to the errors, then returning the fail response
$apiResponse->sendFailResponse(['message' => 'Original error message from $data', 'test' => 'Some error sample here (test key is not needed)']);
$apiResponse->sendFailResponse();

// Sample #6: adding multiple errors to the errors, then returning the fail response
$apiResponse->addError(['message' => 'Custom Error Message #2', 'test' => 'Sample Error #2']);
$apiResponse->addError(['message' => 'Custom Error Message #3', 'test' => 'Sample Error #3']);
$apiResponse->sendFailResponse();
Sample Success Response
{
    "success": true,
    "message": "",
    "data": [
        "Testing a success message",
        {
            "sample": "Success #1 Message"
        }
    ],
    "errors": []
}
Sample Failure Response
{
    "success": false,
    "message": "",
    "data": [],
    "errors": [
        {
            "message": "Custom Error Message #1",
            "test": "Sample Error #1"
        },
        {
            "message": "Custom Error Message #2",
            "test": "Sample Error #2"
        },
        {
            "message": "Custom Error Message #3",
            "test": "Sample Error #3"
        },
        {
            "message": "Error Message.",
            "test": "Testing an object being added to the errors"
        }
    ]
}

HttpPost Class

Documentation Coming Soon!

GenericFunctions

Documentation Coming Soon!

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-05-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固