PHP code example of madewithlove / htaccess-api-client
1. Go to this page and download the library: Download madewithlove/htaccess-api-client 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/ */
madewithlove / htaccess-api-client example snippets
use Http\Factory\Guzzle\ServerRequestFactory;
use Http\Adapter\Guzzle6\Client;
use Madewithlove\HtaccessClient
$client = new HtaccessClient(
new Client(),
new ServerRequestFactory()
);
$response = $client->test(
'http://localhost',
'RewriteRule .* /foo [R]'
);
$response->getOutputUrl(); // "http://localhost/foo"
$response->getLines();
/*
array(1) {
[0]=>
object(Madewithlove\ResultLine)#30 (5) {
["line":"Madewithlove\ResultLine":private]=> string(23) "RewriteRule .* /foo [R]"
["message":"Madewithlove\ResultLine":private]=> string(98) "The new url is http://localhost/foo
Test are stopped, a redirect will be made with status code 302"
["isMet":"Madewithlove\ResultLine":private]=> bool(true)
["isValid":"Madewithlove\ResultLine":private]=> bool(true)
["wasReached":"Madewithlove\ResultLine":private]=> bool(true)
}
}
*/