CakePHP memcached configuration in core.php or bootstrap.php - cakephp

I am trying to figure out where to setup my memcached configuration in CakePHP 2. Both core.php and bootstrap.php have sections to set up any cache such as memcached, but I still haven't figured out which file to use.
Also the CakePHP documentation is not so clear about this in my eyes.
Could anyone point out what part of the memcached configuration goes into which file please.

Really, you can place configuration values anywhere you would like, even in their own files as long as you load them in core.php or bootstrap.php. However, the default 2.0 core.php file states that other cache configurations should be in bootstrap.php as stated here: https://github.com/cakephp/cakephp/blob/master/app/Config/core.php#L349.
FWIW, we load addition configuration files depending on an environment variable (APP_ENV) as well as a location specific one that overrides all others. We call it core-local.php but the name doesn't really matter as long as it's not tracked in your VCS.
Edit:
Here's how we load environment specific configs. This is towards the end of our core.php so that the configs loaded after it are not overwritten.
$env = getenv('APP_ENV');
if (is_readable(dirname(__FILE__) . "/core-{$env}.php")) {
Configure::load("core-{$env}");
}
End Edit
Lastly, the CakePHP docs are really easy to edit and PRs are very welcome. If you think you can clarify the docs just click on the link at the top of the documentation page and edit away. You can then use the GitHub UI to submit the PR. No editor or git binary is necessary.

Related

how to enable various cache in cakephp 2

I have researched on the same but there is no any detailed tutorial available, using which any new user of cakephp can start work on that.
What I want to do:
how to enable all cache : view,query,any other if is there(which changes needed in core.php and in any other file)
What I did
I tried to enable cache, by reading documentation from cakebook
http://book.cakephp.org/2.0/en/core-libraries/caching.html
but nothing working for me, and most important how to check that cache is working or not?

Preparing to go live with website - what to do or not?

I have finally my project ready to go live, is there a check list of things to go through before uploading the files to the webserver?
Are there any Files or Folders to be deleted before going live.
Version of cake: 2.3.8
I found out to set the debug level to 0.
Set the cookie in core.php
Do I need to remove the following folders?
/app/Console
/lib/Cake/Test
/lib/Cake/TestSuite
Any other security advise please?
Thanks a lot.
Don't deploy anything to production that isn't needed. If your project doesn't require those folders to function, then don't deploy them.
Make sure to check out the short deployment guide from the cake docs.
Also here's a more general website launch checklist.
I recommend making sure your deployment process resets caches appropriately. This can differ depending on how you have things set up, but by default CakePHP uses a file cache. Regardless, it can really hose you to let the cache linger when things should be updated like model schema, etc. For example, see my answer to another StackOverflow question.

Wordpress URL Change on submit

I currently have a website i'm working on that I have taken over from another individual, I dumped his SQL file into my database and everything seems to be ok apart from one thing. Whenever I try to log in to the back end or if I try to go elsewhere, it will add an additional .co.uk to the address bar, making it like so:
From: www.domain.co.uk to www.domain.co.uk.co.uk
I've had a dig in the database but I really can't find anything and i've never faced this issue before, could anyone shed some light on this for me? Maybe just let me know where I could look within the database to identify the problem, many thanks.
Take a look at the .htaccess file in the root folder, which is hidden and may contain rewrite rules.
Also, I recommend you use this plugin for migrations:
http://wordpress.org/extend/plugins/wp-migrate-db/
I use it whenever I move from localhost to a live site and vice versa. It will also ensure your widgets are preserved, since doing a find replace will cause the object serialisation syntax WordPress uses to break.
After migrating, you need to visit Settings > Permalinks so the .htaccess file can be updated according to the new URL for rewrites.

Missing Controller Error in Cakephp 2.0.4

Apologies if I ask a silly question, I am quite new to CakePhp
I have installed Cakephp 2.0.4 on dev.ayumma.com (Used Git Clone on, Amazon ec2 machine, amazon linux, with mysql php5, etc.)
I have configured apache with mod_rewrite loaded (you can verify here). I am using the cake 2.0 documentation for a development installation.
My paths are absolute you can see that here as I print them on the page.
I am copying code from the cakephp 2.0 documentation.
Code is in the correct folders, case is correct on file names, and I even copied and renamed files according to error message, just in case. Database was created from the code on the tutorial. The routes.php file has required CAKE . 'Config' . DS . 'routes.php';.
I have ruled out file location. Files are in the correct folders
I have ruled out mod_rewrite. Seems to be loaded, not sure how else to test.
I have ruled out absolute paths. The paths show up correctly.
I have ruled out the routes.php file. Last line is correct.
What am I missing? Any help would be appreciated. I am sure its probably something simple, but at this moment it is out of my grasp.
Offending page is here.
The erorr message means that you have not created the required controller for the posts table.
Make sure you have created Controller, Model and Views for posts table. controller file should be named as PostsController.php, model file as Post.php and View files are named as index.ctp, view.ctp etc .

Cakephp: Include php script in .ctp file

I want to add captcha in myfile.ctp. For this i found source for captcha along with some resource files includs(js, php).
I know the folder for js files & include this file using <?php echo $javascript->link(array('ajax_captcha.js'));?>. But I don't know where to place .php file &
also how to include it in myfile.ctp
Or if anybody help me to implement Captcha in Cakephp.
For your js, use $javascript->link('ajax_captcha',false); Not the omission of the extension. false will place it in the section of the HTML. This will look for the script in webroot/js
Personally, I would just use a standard php include directive for the php side of things, bearing in mind that the location will be relative to webroot, i.e. '/myPHP/captcha.php'will be webroot/myPHP/captcha.php.
Don't forget, CakePHP is PHP.
I'd use a plugin or component, http://bakery.cakephp.org/articles/view/captcha-component-with-phpcaptcha
This works very well with PHPCaptcha for all your Human vs Computer shenanigans. Feel free to google around for your preferred plugin/component.
There is another article in the bakery - Integrate CakePHP with Kcaptcha (read the comments there too). I have successfully implemented kcaptcha in my application.
Elements are a good way to pull code that gets sprinkled over and over around various views:
http://book.cakephp.org/2.0/en/views.html#elements

Resources