Category: PHP Frameworks
CakePhp 3.x | Declaration of user defined constants
In cakephp 3 we declare constants in bootstrap.php file under /app/config folder. A constant can be declared as: Configure::write(‘CONSTANT_NAME’, Value, true); Example: Configure::write(‘USERNAME’, ‘Webners’, true); To use this constant in another file, use this: use Cake\Core\Configure; Now the constant can
PHP and AWS | Copy AWS S3 file to local folder
How to copy a file from Amazon s3 to some local folder using PHP code $t=file_put_contents(‘[Destination file address]’, file_get_contents(“[S3 url]”)); Here $t will get the size of file in bytes if successful otherwise 0. Before executing this make sure that
Cron jobs in Totara
When I made any new changes to the audience or add a new user(s) to existing audience in totara, it didn’t reflect in the member area of that audience. Sometimes it doesn’t even show changes made for many days because
CakePHP | Calling Web API in CakePhp 3.x
Web API requests in CakePhp 3.x and difference from curl in php. Cakephp provides an easy method to communicate with webservices as compared to core PHP. In core php we make api requests using curl. Below is the sample code
Sendgrid | Display sender name with email in “from” field
If we want that when we send email to our users using sendgrid api then the name of the sender (if we provide) should appear along with sender-email then follow the process given below : To accomplish this, we just
AWS Amazon EC2 – Install php5.6 in Amazon linux
In Amazon Linux, it is not yet packaged with php5.6. When we install PHP by a standrad command: $yum install php* 1. It will install PHP version 5.3 Below are the steps to update PHP version from 5.3 to 5.6
CakePhp | beforeSave and afterSave Callback Methods
beforeSave(): This function is called automatically before every save or update operation. This function must return true if you want to continue save process. The data for save, if needed in this function, will be in $this->data. Syntax: class MyModel
PHP | What is the purpose of data filtering in PHP?
Data Filtering is required in PHP to validate input and sanitize input received. Generally, we need to validate data before inputs need to be saved or used in our webpage. Wrong data inputs may cause exceptions or erroneous state in
PHP | Short introduction to traits in PHP
In PHP, the trait is a method of code re-usability. Php is single inheritance programming language. So there is a limitation of code reusability due to single inheritance. Traits in PHP is basically a method of code reusability. Traits have