Created
June 12, 2014 11:25
-
-
Save ayonliu/433a506a516b6bfe0e70 to your computer and use it in GitHub Desktop.
How to use hessian in laravel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
| app/start/global.php | |
|-------------------------------------------------------------------------- | |
| Register The Laravel Class Loader | |
|-------------------------------------------------------------------------- | |
| | |
| In addition to using Composer, you may use the Laravel class loader to | |
| load your controllers and models. This is useful for keeping all of | |
| your classes in the "global" namespace without Composer updating. | |
| | |
*/ | |
ClassLoader::addDirectories(array( | |
app_path().'/commands', | |
app_path().'/controllers', | |
app_path().'/models', | |
app_path().'/database/seeds', | |
// add for hessian | |
app_path().'/hessian', | |
)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// app/controllers/HomeController.php | |
class HomeController extends BaseController { | |
// method for client to call | |
function getFile($file) | |
{ | |
return $file . ' hessian'; | |
//return $file; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// app/routes.php | |
// hessian client | |
Route::get('/hessian', function() | |
{ | |
//$fp = fopen(dirname(__FILE__).'/unit_tests/ok.png', "r"); | |
$options = new HessianOptions(); | |
$options->version = 2; | |
$options->transport = "http"; | |
$url = 'http://localhost/laravel/public/hessianServer'; | |
//echo "Testing in url $this->url<br>"; | |
$proxy = new HessianClient($url, $options); | |
$fp = 'hello'; | |
$data['fp'] = $fp; | |
//header('Content-Type: image/png'); | |
// call server method | |
echo $proxy->getFile($data['fp']); | |
}); | |
// hessian server | |
Route::post('/hessianServer', function() | |
{ | |
$testService = new HomeController(); | |
$server = new HessianService($testService, array('displayInfo' => true)); | |
$server->handle(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment