PHP Frameworks Archives - Page 7 of 13

WordPress | Developing Custom scheduler in WordPress

Author - Harleen Kaur
|
0 Comments
|

Suppose you want to design a custom scheduler in wordpress plugin instead of using wordpress scheduler which has fixed values of recurrence which are ‘hourly’, ‘twicedaily’,’daily’. And if you want to make the scheduler dynamic instead of making it static i.e. instead of setting the fixed scheduler value Read more…

PHP | Only first word showing in textbox from assigned sentence

Author - Webner
|
0 Comments
|

Problem: After the first space in the string no data appears in the input field.

There is an issue when a string contains words with spaces and we want to display the whole string in an input field but after the first space, no data is displayed in Read more…

Adding custom merge tags to the Gravity forms

Author - Komal

Merge Tags in gravity forms are the tags that are used to dynamically populate the field values in the form content in gravity forms like IP address, browser name, logged in user name etc . There are many merge tags available in the gravity forms by default.

But sometimes there may Read more…

WordPress | How to retrieve query variables in plugins

Author - Harleen Kaur
|
0 Comments
|

Suppose the URL contains query string for example www.mywebsite.com/sme_page?q=12
then the value of query variable can be retrieved in PHP using the get method such as:
<?php
echo $_GET[‘q’];  
?>
While creating a plugin for WordPress, to retrieve a value of query variables Read more…

CakePHP 3.x | How to change URL of your website to hide controller/action name

Author - Richa
|
0 Comments
|

Requirement: While running the website in browser, the url path shows controller name followed by the action name and parameters list. In that case the url looks like:

www.xyz.com/User/showDetails/

We may come across two types of requirements.

Displaying only the action name without showing Read more…

Ubuntu | Remove sendmail completely

Author - Ishpreet Kaur

Problem: I installed sendmail in my ubuntu system with the help of link http://lukepeters.me/blog/getting-the-php-mail-function-to-work-on-ubuntu. I installed it to test php mail functionality on localhost for my project. It was working slow, therefore, after testing, I wanted Read more…

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
|
1 Comment
|

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…