Using components in Cakephp 3+

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27<?phpnamespaceApp\Shell;useCake\Console\Shell;useCake\Controller\Component;useCake\Controller\ComponentRegistry;useApp\Controller\Component\YourComponent;classYourShellextendsShell{publicfunctioninitialize(){parent::initialize();$this->Your=newYourComponent(newComponentRegistry());}publicfunctionyourMethod(){$this->Your->component_method($params1);}}?>

Creating robot.txt for CakePHP

What is robots.txt?Robots.txt is a text file webmasters create to instruct web robots (typically search engine robots) how to crawl pages on their website. 

To learn more and see examples of robots.txt :

Cakephp - MissingControllerException Controller class Robots.txtCreate the robots.txt in your webroot/directory.

CakePHP Change Default Timezone Set

Set timezone in App/Config/bootstrap.php (Cakephp 2.6+) Set timezone in config/bootstrap.php (Cakephp 3)

1 2 3 4 5 6 7 8<?php/* * Set server timezone to UTC. You can change it to another timezone of your * choice but using UTC makes time calculations / conversions easier. * Check for list of valid timezone strings. */date_default_timezone_set('Asia/Manila');?>
Check for list of valid timezone strings.

Custom favicon sizes for CakePHP

Generate your icon here for different sizes :

Put your images/icons inside webroot/ico directory. If you use theme/plugin, put it inside the webroot/ico of the theme

Open your default.ctp and put this code inside <head></head>:

1 2 3 4 5 6 7 8 9 10 11 12<head> <?phpecho$this->Html->meta('android-icon-36x36.png','/ico/android-icon-36x36.png',['type'=>'icon']);echo$this->Html->meta('apple-icon-57x57.png','/ico/apple-icon-57x57.png',['type'=>'icon','sizes'=>'57x57']);echo$this->Html->meta('apple-icon-72x72.png','/ico/android-icon-72x72.png',['type'=>'icon','sizes'=>'72x72']);echo$this->Html->meta('apple-icon-76x76.png','/ico/apple-icon-76x76.png',['type'=>'icon','sizes'=>'76x76']);echo$this->Html->meta…


Run the below query you can get the Data Base Size in MySQL. 

If you run the query which is given below in MySQL Query Browser then you will get the two columns first will display the Data Base Name and the second will display the Data Base Size in MB. 

This will display list of all database :

1 2SELECTtable_schema"Data Base Name",sum(data_length+index_length)/1024/1024"Data Base Size in MB"FROMinformation_schema.TABLESGROUPBYtable_schema;

This will display specific database db_name:

1 2SELECTtable_schema"Data Base Name",sum(data_length+index_length)/1024/1024"Data Base Size in MB"FROMinformation_schema.TABLESWHEREtable_schema="db_name"

Ajax Request to PHP

Client Side
1 2 3 4 5 6 7 8 9 10 11 12 13$.ajax({url:'/path/to/server',type:'POST',data:{first_name:firstName,last_name:lastName,address:address,city:city,country:country},success:function(result){varobj=jQuery.parseJSON(result);if(obj.result=='OK'){alert(obj.message);}else{alert(obj.message);}}});

Server Side
response from php file
1echojson_encode(['result'=>'OK','message'=>'This is message']);

The Importance of Redesigning Your Website

Redesigning a website takes time and money, but in the end a revamp is a wise investment. Your website is essentially a virtual business card, and your strongest online marketing tool.

Whether you’re looking for the best web development in LA or revamping in NYC, make the most of business by keeping your website fresh, up-to-date, and user-friendly.

Outdated The Web is constantly changing: Web technology that was once considered cutting-edge is most likely out-of-date today. A website makeover will give you and your business an advantage in the competitive, online sphere..

In fact, design is a leading factor in user trust. According to a study titled, “Trust and Mistrust of Online Health Sites,” 94 percent of the participants agreed that an updated, better looking website is more trustworthy than an outdated design, even if the information displayed on both is accurate and of equal quality.

Usability If your readers are unable to find what they’re looking for quickly, they will leave. To pr…