承接 fortytwo-studio/webfaction-php 相关项目开发

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

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

fortytwo-studio/webfaction-php

Composer 安装命令:

composer require fortytwo-studio/webfaction-php

包简介

PHP wrapper for the Webfaction XML-RPC API

README 文档

README

Build Status

webfaction-php

Simple PHP wrapper for the WebFaction XMLRPC API

Installation

Install using composer

composer require fortytwo-studio/webfaction-php

or add to your composer.json file's "require" section

"require": {
  "fortytwo-studio/webfaction-php": "^1.0",
}

(don't forget to run composer install or composer update)

Overview

This is a PHP wrapper for interacting with the WebFaction XMLRPC API. It's extremely thin, methods follow the naming conventions(camelCase rather than snake_case) and parameter ordering (ignoring session_id) of the XMLRPC API

Usage

include the client in your project class.

<?php
    use FortyTwoStudio\WebFactionPHP\WebFactionClient;
    use FortyTwoStudio\WebFactionPHP\WebFactionException;
    
    class MyAwesomeClass {
        ...
    }

To create a connection to the API new up an instance of the WebFactionClient with your API credentials:

    $wf = new WebFactionClient('USERNAME', 'PASSWORD', 'MACHINE', 'VERSION');

You can then perform interactions with the API using the methods.

Example - Provision a new mysql database and user

<?php

// include composer's autoloader (this'll vary depending on your application)
// presuming this file is in a "webroot" type folder...
include(__DIR__ . '/../vendor/autoload.php');

use FortyTwoStudio\WebFactionPHP\WebFactionClient;
use FortyTwoStudio\WebFactionPHP\WebFactionException;

class MyAwesomeClass
{

    public function createDatabase($username = "new_db_user", $dbname = "my_new_db")
    {
        try
        {
            // create a connection to the API, use your own credentials here, obvs
            $wf = new WebFactionClient('USERNAME', 'PASSWORD', 'MACHINE', 'VERSION');

            // static method to generate random strings of given length
            $db_pass = WebFactionClient::generatePassword(21);

            // https://docs.webfaction.com/xmlrpc-api/apiref.html#method-create_db
            $database = $wf->createDb($dbname, 'mysql', $db_pass, $username);

            // https://docs.webfaction.com/xmlrpc-api/apiref.html#method-change_db_user_password
            //otherwise it doesn't seem to use it. Possibly because we're creating the user at the same time as the DB above
            $wf->changeDbUserPassword($username, $db_pass, 'mysql');

        } catch (WebFactionException $e)
        {
            // Something went wrong, find out what with $e->getMessage() but be warned, WebFaction exception messages are often
            // vague and unhelpful!
            return "rut roh, this went wrong: " . $e->getMessage();
        }

        // database created, keep a record of $db_pass if you want to use it somewhere!
        return "$db_pass";
    }

}

echo (new MyAwesomeClass())->createDatabase(); // if you didn't change the credentials in this example => rut roh, this went wrong: LoginError

Changelog

03/Apr/2018 - 1.1.4

  • Fixed bug on replaceInFile method where multiple replacements were erroring

06/Mar/2018 - 1.1.3

  • altered composer.json to require 4.* of phpxmlrpc
  • update ReadMe

19/Dec/2017 - 1.1.2

  • fixed "Unkown Error" exception on createWebsite on v1 and v2 of the API
  • update ReadMe

29/Nov/2017 - 1.1.1

  • small change to exception message when using an endpoint unavailable to the current version
  • update ReadMe

29/Nov/2017 - 1.1.0

  • update to handle Version 2 of the Webfaction API. This has support for SSL certificate management.
  • fixed bug where some email methods weren't returning a response
  • update ReadMe

01/Aug/2017 - 1.0.0

  • update phpunit
  • travis CI build integration
  • update ReadMe

23/Aug/2016 - initial release.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-08-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固