PHP code example of hk-r / lib-plum

1. Go to this page and download the library: Download hk-r/lib-plum library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hk-r / lib-plum example snippets



// 実行環境に合わせてパスを設定
��で使用するデータ保管用ディレクトリ
		// (書き込みが許可されたディレクトリを指定)
		'data_dir' => '/path/to/data_dir/',

		// ステージングサーバ定義
		'staging_server' => array(

			// ステージングサーバの数だけ設定する
			//
			//   string 'name':
			//     - ステージングサーバ名(任意)
			//   string 'path':
			//     - ステージングサーバ(デプロイ先)のパス
			//   string 'url':
			//     - ステージングサーバのURL
			//       Webサーバのvirtual host等で設定したURL
			//
			array(
				'name' => 'Staging 1',
				'path' => './../repos/stg1/',
				'url' => 'http://stg1.localhost/'
			)
		),

		// Git情報定義
		'git' => array(
			// リモートのURL
			'url' => 'https://host.com/path/to.git',

			// ユーザ名
			// Gitリポジトリのユーザ名を設定。
			'username' => 'user',

			// パスワード
			// Gitリポジトリのパスワードを設定。
			'password' => 'pass'
		),

		// 基本認証パスワードのハッシュ生成アルゴリズム名
		// 'bcrypt'|'md5'|'sha1'|'crypt'|'plain'
		'htpasswd_hash_algorithm' => 'crypt',
	)
);
$plum->set_async_callbacks(array(
	'async' => function( $params ){
		/*
		async
		非同期で実行するコールバック関数を拡張します。
		ここで受け取った `$message` を、
		非同期に `$plum->async($params);` へ転送してください。
		*/
	},
	'broadcast' => function( $message ){
		/*
		メッセージをブラウザに送るコールバック関数を拡張します。
		ここで受け取った `$message` を、
		フロントエンドの `plum.broadcastMessage($message);` へ転送してください。
		*/
	}
));

$json = $plum->gpi( $_POST['data'] );

header('Content-type: application/json');
echo json_encode( $json );


m = new hk\plum\main(

	/* 中略 */

);

$json = $plum->async( $params );