Tag Archives: get

CakePHP3 Cache Example – Using Curl to get a Web page contents


Heres a simple example of using the cache feature of cakephp. We want to grab a webpage contents from the web but we only want to do this once otherwise its going to be slow and waste resources.

The basic idea is that we check if the url is saved in cache, if it is then we read it in otherwise we must use curl to grab it.

CakePHP3’s Cache settings are in the config/app.php file;

/**
* Configure the cache adapters.
*/
'Cache' => [
'default' => [
'className' => 'File',
'path' => CACHE,
'url' => env('CACHE_DEFAULT_URL', null),
'duration' => '+60 minutes',//the duration object should cached for
/*'prefix' => 'mycacheprefix_',*/
],

 

 

CakePHP 3 Cache:
https://book.cakephp.org/3.0/en/core-libraries/caching.html

Cakephp3-form methods GET and POST

23666GET:
to set the method your form is send in cakephp3 as GET;

echo $this->Form->create(null, ['type' => 'get']);

to get the Data sent via get in controller;

$this->request->query['txtboxfromform'];

POST:

//set the method
echo $this->Form->create(null, ['type' => 'post']);

 

//get data
$this->request->data['txtboxfromform'];

Forms in cakephp3:
http://book.cakephp.org/3.0/en/views/helpers/form.html