fortytwo-studio/webfaction-php
Composer 安装命令:
composer require fortytwo-studio/webfaction-php
包简介
PHP wrapper for the Webfaction XML-RPC API
README 文档
README
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.
fortytwo-studio/webfaction-php 适用场景与选型建议
fortytwo-studio/webfaction-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 878 次下载、GitHub Stars 达 5, 最近一次更新时间为 2016 年 08 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 fortytwo-studio/webfaction-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 fortytwo-studio/webfaction-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 878
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 7
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-08-23