PHP Frameworks

Moodle | Calling custom function on an event

Author - Kritika Sood
|
0 Comments
|

Event driven architecture is inbuilt into Moodle. There are various kinds of events present in moodle like:

1. Course completion
2. Course creation
3. Course deletion
4. Course Module creation
5. Category Creation
etc.

On trigger of an event we can call our custom function of custom block Read more…

CakePhp 3.x | Declaration of user defined constants

Author - Parminder Kaur
|
0 Comments
|

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 be accessed Read more…

PHP and AWS | Copy AWS S3 file to local folder

Author - Ashish
|
0 Comments
|

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 the S3 file has access permission and Read more…

Cron jobs in Totara

Author - Webner
|
0 Comments
|

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 of scheduled Cron not running properly and Read more…

CakePHP | Calling Web API in CakePhp 3.x

Author - Parminder Kaur
|
0 Comments
|

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 :

function testAPI() {
header(“Content-type: application/json”);
$url = “https Read more…

Sendgrid | Display sender name with email in “from” field

Author - Manju Kashyap
|
0 Comments
|

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 need to pass an extra parameter “fromname” to the curl Read more…

AWS Amazon EC2 – Install php5.6 in Amazon linux

Author - Webner

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 in Amazon Linux:

Remove Read more…

CakePhp | beforeSave and afterSave Callback Methods

Author - Kailash
|
0 Comments
|

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 extends AppModel {
public
function beforeSave() {
if (isset($this – > data Read more…

PHP | What is the purpose of data filtering in PHP?

Author - Ishpreet Kaur
|
0 Comments
|

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 a webpage.

Data Filtering involves:
Validation:Read more…

PHP | Short introduction to traits in PHP

Author - Parminder Kaur
|
0 Comments
|

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 a similar declaration like the class but it includes Read more…

Moodle | Uploading Scorm Package and some internal function calls

Author - Kailash
|
0 Comments
|

1.Uploading a scorm package (.zip) in moodle:

a. Log-in to moodle, navigate to your course and “turn editing on”:

b. Click “Add an activity or resource” link:

c. Select Scorm package from list and click Add button:

d.Add basic information about the SCORM package that you are Read more…

PHP | Password hashing

Author - Deepika
|
0 Comments
|

Password hashing is the new recommended way to store the password using hashing method (PHP 5 >= PHP 5.5, PHP7). Password hashing is used to encrypt the password similar to the way md5, sha1, sha256 etc do. But this method follows stronger hashing algorithm comparatively. There are two methods Read more…

Selenium | Take UI screenshots when script is executed

Author - Webner
|
0 Comments
|

During testing a website with Selenium, function given below can take screenshot that can help us in cases like when testcase fails and we need the screenshot to see what happened on UI.

Here is function to take screenshot:
public void screenshot(WebDriver driver, String fileName) {
try {
File src = ((TakesScreenshot Read more…

AWS Amazon CloudFront – How to enable cache for whole site

Author - Navneet Kashyap
|
0 Comments
|

AWS Amazon CloudFront is a web service that speeds up serving static and dynamic web content like, .html, .css, .php, and image files and videos. It also integrates with other Amazon Web Services like S3, EC2, Elastic Load Balancer and Route 53. It also works seamlessly with any non-AWS Read more…

PHP | Load Data Infile to insert csv data into Mysql with PHP

Author - Webner

Problem: How to insert csv data into mysql table with mysql query in php. What problems usually you face with this and how to resolve them.

Description: I have csv file with thousands of records. I want to insert these records in mysql table with php Read more…

Moodle/Totara | Creating a new Activity Plugin

Author - Webner

Introduction: In Moodle/Totara we can add a different type of activities to a course by selecting from the list of standard activities available. As shown in the the list below:

But there might be some cases in which we need to add a custom activity to a Read more…

Selenium | Data Driven Framework to read csv data

Author - Webner

During testing, I had a test case to add multiple employees automatically with selenium script so I have implemented Data Driven Framework. Using this we have to read the data from the CSV and register all the users in the system.

Note:  We need to add a jar Read more…

WordPress | Dynamically generating ADF XML format of the form submission

Author - Komal

ADF XML FORMAT

ADF XML format stands for Auto-lead Data Format XML that is an automotive retailing industry standard data delivery format for import and export of automotive customer leads.

This format is used as a way to format the customer data so that the heterogeneous systems Read more…

PHP | core.php and some important settings

Author - Manju Kashyap

In CakePHP application, core.php is configuration file and is located at app/Config/core.php. This file contains various variable definitions and constant definitions that alter the behavior of the application. The description of some important variables and their effect on the application is given below:

Debug:Read more…

Moodle | This page should automatically redirect

Author - Shalini

In my plugin code I was trying to redirect from one page to another page using redirect as follows:
redirect(“success.php?cd=”.$id);
Redirecting to the other page was working but during redirection an intermediate page was being displayed like this:

On click of continue button, it was redirecting Read more…