Categories
CakePHP PHP Tips and Tricks Tools and Technologies

CakePHP 3 – DebugKit Toolbar Not Visible

Are you looking for the solution of DebugKit Toolbar not visible in CakePHP 3? These small tips will help you do that. Ensure you have pdo-sqlite installed & enabled on your machine. Cause debugKit by default uses a sqlite db. If not then follow this instruction.

At first install pdo-sqlite in your machine.

sudo apt-get install php7.0-sqlite

Then restart your server (apache server)

sudo service apache2 restart

Now that will help you to visible the DebugKit Toolbar

 

Categories
CakePHP Career PHP Tips and Tricks

Loading Model Inside Another Model and Controller in CakePHP 3

Sometimes it necessary to load a model inside another model as well as another controller in CakePHP. This article will help you to load a model from another model & controller with CakePHP 3

Load From Model:
$anotherTable = TableRegistry::get('AnotherTable');
$data = $anotherTable->find('list');

CakePHP TableRegistry is a factory of the Table object. It comes with a lot of static function and get() one of them. TableRegistry::get() provides an instance of Table. You can see an example from above snippet.

Load From Controller:
$this->loadModel('AnotherModel');
$data = $this->AnotherModel->find('list');

If you need to load a model from the controller which does not default model of the controller. You can use loadModel() function to get an instance of another model.

Categories
CakePHP PHP

How to Install CakePHP

CakePHP is the most simpler, faster, powerful open source framework. it is written by PHP (Object Oriented)” . It’s follow the MVC (Model View Controller) pattern. Which is most interactive part of it. You can easily build your application require less coding. Let’s I am going to introduce how to Install CakePHP with some step.

Step 1 : Download latest version of CakePHP from cakephp.org and extract the downloaded file.

Step 2 : If you downloaded 2.2.3 then you will see cakephp-2.2.3 >> cakephp-2.2.3 this folder structure. You need to rename the second cakephp-2.2.3 with your desire name like cake.

Step 3 : Copy the folder and paste into your htdocs folder (your local server). and type in your browser “http://localhost/cake” (If you rename with cake name, otherwise write http://localhost/your_desire_name). Then you will see something like this image.

cake_install

Step 4 : After that you need to change the “Security Salt” and ”Security ChiperSeed”. To that go to app/config and open the core.php and you will see this code.

* A random string used in security hashing methods.
*/
    Configure::write('Security.salt', 'DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi');

/**
* A random numeric string (digits only) used to encrypt/decrypt strings.
*/
    Configure::write('Security.cipherSeed', '76859309657453542496749683645');

You need to change those security.salt and security.CiperSeed. Like this

* A random string used in security hashing methods.
*/
    Configure::write('Security.salt', 'fesfsdfsdfsesfdlkfmma;lfm,as,mfcesR2G0FgaC9mi');

/**
* A random numeric string (digits only) used to encrypt/decrypt strings.
*/
    Configure::write('Security.cipherSeed', '7685645641654165416546549309657453542496749683645');

Step 5:  After that rename the file dsatbase.php.default to database.php . For doing that you have to go app/config and you will see the database.php.default

Step 6 : Then create a database and then open database.php file and you will see this code.

public $default = array(
        'datasource' => 'Database/Mysql',
        'persistent' => false,
        'host' => 'localhost',
        'login' => 'user',
        'password' => 'password',
        'database' => 'database_name',
        'prefix' => '',
        //'encoding' => 'utf8',
    );

change the host,login,password,database name with your host,user, password,database name.

Step 7: That’s fine, you have done all things. Now refresh you browser and see you browser.