PHP Frameworks

PHP – Possible reasons of “Allowed memory size exhausted” error

Author - Rita

Most of the times when we get memory exhausted error, we normally think that the memory allocated for php program execution in php.ini file is not sufficient and raise this limit to try to fix the error.

However, code inefficiency could be the reason behind the error. Some examples Read more…

How to add combobox in editable datagrid using jQuery EasyUI

Author - Webner

Following is the code to add Combobox in editable data grid:

Index.html:
<table id=”dg” title=” Combobox in editable datagrid ” style=”width:100%;height:700px”
toolbar=”#toolbar” pagination=”true” rownumbers=”true” fitColumns=”false” singleSelect=”true” autoSave=”true” data-options=”pageSize:50″>
<thead>
&lt Read more…

PHP | Adding text over an image

Author - Richa

In order to add text over an image, following PHP code can be used. Read the comments to understand purpose of code statements:

<?php
header (“Content-type: image/jpeg”); //setting the content type

//variable containing the string to be written on the image
$txt = “Here goes the text to Read more…

PHP | better way to include a file

Author - Kiran Preet

Have a look at this folder structure:

Test
Folder1
Abc.php
Folder2
Qwerty.php

Now in Abc.php file, try to include Qwerty.php using the following code:
Abc.php
include(‘../Folder2/Qwerty.php’)
It will give this error:

Fatal error: Failed opening required Read more…

PHP | How to install CakePHP 3.0

Author - Deepika

These are the steps to install CakePHP 3.0 on Ubuntu machine:

Make sure you have PHP 5.5.9 (CLI) or higher installed. Check php version on your system using this command:

php -v

Run the following commands:

1. Download the composer installer in your Read more…

Introduction to Heroku

Author - Webner

Heroku is an all-in-one cloud based platform which allows software developers to develop and host applications over Heroku cloud. The company was setup in June 2007 which initially supported Ruby programming language. Later on, support for other programming languages such as Node.js, Java, PHP, Python, Scala, Go Read more…

How to send iCal attachment in the email

Author - Kailash

Suppose you are sending an email in PHP and want to send iCal attachment. In PHP this can be achieved as below:

1. Create iCal file content and put in a variable (like $iCal here):

$iCal = “BEGIN:VCALENDAR\r\n
VERSION:2.0\r\n
METHOD:PUBLISH\r\n
X Read more…

Salesforce | Please use TLS 1.1 or higher when connecting to Salesforce using https

Author - Ashish

Salesforce login via PHP Salesforce Toolkit API may throw this exception:

Please use TLS 1.1 or higher when connecting to Salesforce using https

The reason is Salesforce has provided customers with the Critical Update feature Require TLS 1.1 or higher for HTTPS to maintain high Security. If you Read more…

How to access Moodle files outside the Moodle?

Author - Shalini

We can access Moodle outside the Moodle (without login) by passing token in the URL.

For example :

http://localhost/Moodle_new/webservice/pluginfile.php/26/qtype_match/subquestion/17/5/6/PineApple.jpg?token=6yhg9331af9d9284abb36cyjh0c67114a

If token is not be passed into the URL, then it redirects to Moodle’s Read more…

CakePHP bake: SQLSTATE[42S02]: Base table or view not found

Author - Rita

While running cake bake command for cakephp 3.0 we got the following error:

SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘tablename .columnname’ doesn’t exist

The culprit was a column with name test_id in one of the tables. As per bake command’s conventions about foreign Read more…

Heroku | Change PHP session timeout

Author - Webner

In Heroku, there is no way to change HTTP session timeout (or some other php.ini settings) from user interface. For this create a file with name .user.ini and specify the properties in it. This file is to be created in root folder of project.

In our case we Read more…

CakePHP | Redirect from http to https URL

Author - Kailash

If you want to redirect from http to https in CakePHP, generally redirect method code is like this:
$this­->redirect(array(“controller” => “myController”,”action” =>t; “myAction”));
But if your site is running on http protocol it will redirect to the url with http protocol:

‘http://www Read more…

Moodle and Java | Retrieving users’ data from Moodle using External Java Application

Author - Richa

Retrieving users’ data from Moodle using External Java Application

We can write a basic REST moodle client code using Java to fetch users’ records from moodle. Before writing the code, you need to perform below steps in Moodle which are required in order to fetch the data:

1. Create external Read more…

Curl | How to test a Restful web service using curl

Author - Rita

Let’s consider, we have a demo Restful service (created in Java Spring here but you can create in any language) to login user which accepts username and password as input and returns Success/Failure in response.

Request Object : Demo Login Request class :

Response Object :

Here is how to call Read more…

Cakephp 3.0 | Steps to create theme controller

Author - Rita

Description : Cakephp 3.0 provides a way to display different front end view for different clients using Themes. Theme is a plugin which follows the same structure as other cakephp plugins. Before Cakephp 3.0 it was only used to separate front end view for the clients. But in Cakephp Read more…

Add buttons to ACORD forms, submit ACORD form to a webservice

Author - Webner

ACORD pdf forms are editable. We can not only fill data in existing input elements but also add more elements (like new buttons and fields) in the forms and invoke actions to submit data from pdf to an external URL.

In the example below we have an ACORD PDF in Read more…

Javascript | How to post Acord PDF Forms data to a Web URL

Author - Webner

Description : You have Fillable PDF on which you have button “Save Entered Data”. On button you want post the form data to php file.

Solution :

Follow these steps :

1. Open Form with Adobe Acrobat Pro. Goto–>Tools.

2. From Tools, Go to Tools–>Rich Media.

3. Click on Select Object Read more…

PHP | Why HTML to PDF does not show same styling as on HTML page?

Author - Webner

Sometimes, HTML to PDF conversion does not show the same styling in PDF as it shows in HTML.

There are several reasons for that such as :

1. Bootstrap classes:

Using bootstrap classes in creating PDF could be the problem. A4 paper size has different width and height than our screen Read more…

PHP | Deleting files from local machine (unlink(): No such file or directory)

Author - Kiran Preet

Assume following is the path on your system in which you want to delete some files through code (unlink function):

C:\wamp\www

Now if we use the same address in source variable (“C:\wamp\www”), it gives the following error:

unlink(): No such file or directory

This is because Read more…

How to add new custom HTML pages in Totara/Moodle

Author - Neelam

Totara / moodle does not have the default feature to add custom HTML pages and display on the site. But we can achieve this by installing a plugin:

“General plugins (Local): Static Pages”

Steps to install and use this plugin in Totara:

1. Install the plugin like any other Read more…