Cakephp and Laravel are MVC frameworks for php. Both frameworks have totally different application structure. In the following document I have described all the important folders and their respective locations in Cakephp and Laravel (project_name is the root folder of your project)
Some other Important Points Read more…
There are multiple ways to enable/disable maintenance mode in Moodle.
Enable Maintenance Mode:
* Go to the Site Administration.
* Click on Server.
* Click on Maintenance Mode option:
* On the next screen: Maintenance mode ->Select “Enable” from drop-down. And write the message which Read more…
In wordpress, we can also change the appearance of wp-login page. There are so many plugins available for this purpose like Alter – White Label WordPress plugin. We can change the appearance of wp-login page through this plugin like I have changed the background image and color in this Read more…
1. Open config/app.php file inside your project and then modify the default email configuration and setup your SMTP account there:
‘EmailTransport’ => [
‘default’ => [
‘className’ => ‘SMTP’,
// The following keys are used in SMTP transports
‘host’ => ‘ssl://smtp.gmail.com’,
‘port’ => 465,
‘timeout’ => Read more…
In cakephp we do not need to set hard coded relative paths.There are methods by calling which we can build the url dynamically.
To get the base url use
Router::fullBaseUrl(); => http://localhost //Output
To get the Application Url
Router::url(); =>/CakeApp/ //Output
To build Read more…
We have mail() function to send emails in PHP. It uses built in sendmail command that uses local mail server to send emails. PHPMailer, on the other hand, is very different. Rather than relying on sendmail, it communicates directly with the SMTP server and relays the mail itself.
One of Read more…
1. Click on the database (from list of databases on the phpMyAdmin home screen) in which you want to rename table name.
2. You will see a list of tables on click of the database.
3. Select the table and there is a dropdown below the tables with Read more…
PDO stands for PHP Data Objects. PDO is a consistent way to access databases.
Today, mostly websites or desktop based applications store their data in databases. Therefore, PHP has also provided the way to connect with databases.
PHP supports following ways to connect to the database:
1. Mysql Read more…
In Moodle when we create a new course we have an option to add summary/description of course. We can use this summary anywhere while showing courses. This summary could be anything. It can be simple text, image, multimedia or hyperlinks.
Hyperlinks are 2 forms:
Hyperlink launches a Read more…
We can send ical attachment in email using attach ical file (filename with .ics file extension).
For example, following is the object containing the information about ical like event start date and time, location, event summary etc:
$ical_content = “BEGIN:VCALENDAR
PRODID://Drupal iCal API//EN
BEGIN:VEVENT Read more…
FPDF (To generate PDF files)
Using PHP we can generate PDF files dynamically. FPDF is a free PHP class that contains a number of PHP functions with the help of which we can create and manipulate PDFs. To get started with FPDF, we just need to download FPDF library from Read more…
Whenever the situation occurs to rerender the page contents without reloading the whole page, we use ajax in it. By using ajax we get the response data back in the success function which we will show on the screen. Let’s have a look:
In the above screenshot Read more…
When we pass a floating point value to a variable, then the value which we store in the variable is not the actual value but it is something approximately near to that number which transfers to that variable.
Let us understand this by a PHP example:
<?php Read more…
In Cakephp, console applications are useful in running background processes and can be run without access to web browser. The CakePHP console provides a framework for creating shell scripts.To run the cakephp functions, first of all create a shell to use in console.
For example, create a TestShell in Read more…
Error: Call to undefined function mcrypt_encrypt()
Description: In one of our project, I was trying to save a field value in encrypted format in the database, using PHP, which could be retrieved back to its normal value, where we need to display it.
So for that Read more…
If we follow cakephp rules to create a form then we can use cakephp inbuilt functionality like we don’t need to assign labels to form fields. Cakephp automatically creates a label for each form field also in case of update/insert validation error messages, the message is automatically shown Read more…
While working on two servers, we can take the backup of database on one server using mysqldump command in php.
exec(‘mysqldump –host ‘.$dbhost.’ –user ‘.$dbuser.’ –password=’.$dbpass.” “. $dbname.’ > ‘.$dbname.’.sql’);
After creating dump of database, user can move the dump database file from one server to another Read more…
Scaffolding in CakePHP
Application scaffolding in CakePHP is a technique that allows the developer to define and create a basic application that can create, retrieve, update and delete objects. Basically CRUD (create, Read, Update, Delete) data operations are common in most of the applications.
Scaffolding basically provides temporary structure or Read more…
How to specify an extra field (not existing in the table) while fetching data from database using find method? Solution is explained below.
Assign value to virtual field before find function call:
$this->virtualFields[‘virtual_field_name’] = ‘any value’;
Use virtual field in find function:
$result = $this – > find(‘all’,
‘fields’ => array Read more…
By default, each cURL request can access only SSL certified websites. However, at times it is required to access those sites which are self-signed. To verify that your cURL request is able to access self-signed websites or not, use below command:
curl <URL of the domain to Read more…