Nice article, seems very thorough. Just a quick comment to point out that some extra spacing seems to have been introduced into your code. There are 29 occurrences of ` -> `. :)
This behavior is great, but I can only use it to access web services hosted on our internal network, therefore it is not as useful as it could be in its current state.
I ran the test case and got 17/17 fails since I can't access cakephp.org without going through a proxy. :)
I know you intended to remove any external dependencies, but proxy support is easily accomplished using cURL. For example, I had planned to replace the need for the following code:
Model Class:
<?php
if (!function_exists('curl_init')) {
die('PHP CURL library not enabled. (Uncomment extension=php_curl.dll in php.ini)');
}
$ch = curl_init();
$options = array(
CURLOPT_URL => $requestURL,
CURLOPT_PROXY => 'proxy.example.com',
CURLOPT_PROXYPORT => '8080',
CURLOPT_RETURNTRANSFER => true);
curl_setopt_array($ch, $options);
$body = curl_exec($ch);
curl_close($ch);
//pr($body);
?>
I don't know how easy this is to implement without using cURL, as I have never tried, but just thought I would make you aware of this slight downfall. :)
Controller Class:
<?phpfunction index($searchText = null) {
// redirect when search text is posted
if (isset($this->data['Model']['search_text'])) {
return $this->redirect(array('id' => $this->data['Model']['search_text']));
}
// setup search conditions (if any)
$conditions = null;
if ($searchText) {
$conditions = array('or' => array(
'Model.field LIKE' => '%' . $searchText . '%',
'Model.field_2 LIKE' => '%' . $searchText . '%',
'Model.field_3 LIKE' => '%' . $searchText . '%',
'Model.field_4 LIKE' => '%' . $searchText . '%',
'Model.field_5 LIKE' => '%' . $searchText . '%',
));
}
// set data for view
$this->Model->recursive = 0;
$model = $this->paginate('Model', $conditions);
$this->set(compact('model'));
}
?>
Bear in mind that this implementation performs an "exact phrase" search. One could have an "all words" search by splitting $searchText on spaces and generating a larger $conditions array.
Are you planning to add proxy support?
This behavior is great, but I can only use it to access web services hosted on our internal network, therefore it is not as useful as it could be in its current state.
I ran the test case and got 17/17 fails since I can't access cakephp.org without going through a proxy. :)
I know you intended to remove any external dependencies, but proxy support is easily accomplished using cURL. For example, I had planned to replace the need for the following code:
Model Class:
<?php
if (!function_exists('curl_init')) {
die('PHP CURL library not enabled. (Uncomment extension=php_curl.dll in php.ini)');
}
$requestURL = $this->requestURL . '?' . http_build_query($params);
$ch = curl_init();
$options = array(
CURLOPT_URL => $requestURL,
CURLOPT_PROXY => 'proxy.example.com',
CURLOPT_PROXYPORT => '8080',
CURLOPT_RETURNTRANSFER => true);
curl_setopt_array($ch, $options);
$body = curl_exec($ch);
curl_close($ch);
//pr($body);
?>
I don't know how easy this is to implement without using cURL, as I have never tried, but just thought I would make you aware of this slight downfall. :)