PHP Frameworks Archives - Page 10 of 13

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…

Using UNION syntax in CakePHP 2.4.6

Author - Manju Kashyap

Following UNION syntax works properly in CakePHP 2.4.6 version but it doesn’t work in CakePHP 2.5.2 version:
$unionQuery = $dbo->buildStatement
(
array(
‘fields’ => array( required fields),
‘table’ => $dbo->fullTableName(database_table_name),
‘alias’ => ‘customObject1’,
‘limit’ => null,
‘offset’ => null,
‘joins Read more…

Heroku | An introduction to Procfile and its use

Author - Webner

Introduction: We can make our Heroku app run different type of processes by creating a Procfile in the app.
There is a specific structure and syntax that we need to follow while creating a Procfile. Following are the main points to be considered while creating a Procfile:

The Procfile must Read more…

Zoho | Create Zoho Subscription using the PHP and subscription API

Author - Webner

We can create new Zoho Subscriptions via code by using PHP curl and with the help of Subscription APIs.

Below is the sample code which is required to create a subscription:

$headerArray = array(“Content-Type: application/json;charset=UTF-8”,
“X-com-zoho-subscriptions-organizationid: 00000000”,
“Authorization: Zoho-authtoken ——–Auth Read more…

PHP | Use Of strtr() function

Author - Webner

In PHP if you want to replace multiple variables of the string at one go you could use strtr() instead of using str_replace().

Example :

$vars = array(
‘##session_date##’=>$sessiondate,
‘##session_time##’=>$sessiontime,
‘##conferencelinenumber##’ =>$conferencelinenumber,
‘##pincode##’ =>$pincode,
‘##coachingcommnets##’=>$coachingcomments,
‘##actioncommitmnets##’=>$actioncommitmnets,
‘##reminders##’=> ‘ ‘,
‘##name##’ =>$name,
‘##breakline##’=>'<br><br>’,
);
$BODY=strtr Read more…

CakePHP | How to skip CakePHP authentication for some controller methods

Author - Rita

Description: By default, CakePHP authentication is applied to all application controllers. So it does not allow users to perform any of the action without login.

Solution: Each controller has a beforeFilter method which runs when some action is called from controller. Add below lines to your method:
Public function beforeFilter Read more…

PHP | Header function not working

Author - Webner

Code :
Function getredirect($subcontactid)
{
echo”contactid”.$subcontactid;
header(“location:https://subscriptions.zoho.com/app#/customers/$subcontactid”);
exit;
}

The header function in the above code does not work. But when we remove the echo from the code, it works properly.

Code after removing echo :
Function getredirect($subcontactid)
{
header(“location:https://subscriptions Read more…

Generate getter/setter for PHP Classes in Eclipse

Author - Webner

Using PHPGen Eclipse plug-in one can automatically generate getter /setter methods for instance variables.

Note: This Plugins is not available in Eclipse Marketplace.

Steps For Installation:

Start Eclipse and add “Help> Install New Software” from following URL: http://loge5.de/downloads/Eclipse/:

Click Add, enter http Read more…

How to use SimpleSAMLPhp as a Service Provider for authenticating users?

Author - Ishpreet Kaur

How to use SimpleSAMLPhp as a Service Provider for authenticating users? Some Basic steps to start using simplesamlphp.

1. Download stable version of SimpleSAMLphp from this link:

Click here

2. Go to the directory or your workspace where you want to install simpleSAMLphp, extract the zip file. Give Read more…

CakePHP | Using Elements for common code

Author - Rita

Problem: How to separate redundant piece of code from your view using cakephp 3.0.

Description: Let’s take an example. You have a list of products to display. We show products at many places such as

1. Show all products.

2. Show products of the specific category.

3. Show Read more…

PHP | Rename all the files in zip and then extract zip in PHP

Author - Kiran Preet

Description: In one of our PHP projects, we wanted to rename all the files in zip folder and then extract the zip.

The code for this is written below :

$zip = new ZipArchive;
$res = $zip->open($sourceFolder.’\’.$file);
for ($i = 0; $i < $zip->numFiles; $i++)
{
$filename = $zip->getNameIndex($i);
$newname;
$arr Read more…

Moodle | New lang strings not accessible

Author - Kritika Sood

In Moodle we had declared some new strings in lang file of a plugin like this:

$string[‘LIBRARY_NAME’] = ‘E-Lab’;
$string[‘BOOK_READ_SUCCESS’]=’Congratulations on reading the book’;

We wanted to use it in view.php file of the plugin like this:

$result=Get_String(‘BOOK_READ_SUCCESS’, ‘plugin name’);

But the output was Read more…

PHP | How to merge multiple PDFs into single file using pdftk

Author - Webner

Using PDFtk we can merge multiple files into a single file using a command like this:

Example : pdftk file1 file2 output file3.

Sample code to accomplish the same using PHP is given below:

$arrayOfPDFFiles;
$outputPDFName = “mergeResult.pdf”;
$dir =”Files/GeneratedPDFs/”;
for($i =0;$i<sizeOf($arrayOfPDFFiles);$i++)
{
$multiplePDFs = $multiplePDFs Read more…

Moodle/Totara | Upgrade Moodle database after making changes to a plugin

Author - Webner

In one of our Moodle projects, we modified a plugin’s code to add extra functionality to plugin. The modification in plugin’s code was not reflected and Moodle showed the older version of plugin.

To solve this problem, we upgraded the Moodle database and changes in plugin’s code Read more…

Eclipse | Undo deleted file in Eclipse

Author - Parminder Kaur

Problem: Undo deleted file in Eclipse

Solution: We were working on a project in Eclipse. Accidentally one of the PHP files got deleted in which code was written. Eclipse does not use the Linux ‘Trash’ but keeps local history from where we were able to recover the file.

Follow these Read more…