Synchronize wordpress with limesurvey

In my previous post, I wrote how to use wordpress functions outside.

Suppose we want to add wordpress header and footer design in limesurvey template. Following are the steps.

1. Create copy of default template in limesurvey.
2. Activate it through survey settings.
3. Now you want to upload that php file which I defined in my previous post. But when you try to upload, it gives message of not supported file system.
4. So, we need to manually upload file in template folder which is currently created.i.e limesurvey/uploads/template/copy_of_template_directory.
5. As, limesurvey template file is .pstpl format which does not support direct inclusion of php files.
6. So, the method is to call php file through AJAX function.

<div id="demo"></div>
<script type="text/javascript" charset="utf-8">
$.ajax({
url: "{TEMPLATEURL}demo.php",
type: "POST",
success: function(result){
// Load the remote file contents into the script parent element
$("#demo").append(result);
}
});
</script>

Above code helps to append the php code in your demo division. you can define this division where ever you want to embed the php code.

Cheers!

Use WordPress theme functions externally.

If you want to call any wordpress function outside , you need to have access of its wp-load.php file which load all wordpress functions.

Suppose, you want to display header and footer of wordpress website in your web browser.

1. Create index.php

2. Copy, this code to index.php file which fetch its parts.

<?php
define('WP_USE_THEMES', false);
require('blog/wp-load.php');
get_header();
get_footer();
?>

You can call any part of wordpress like sidebar but you just need to find out its function name and call it in the required file.

Cheers!

Install Laravel in your Ubuntu 14.04

Below given are the server requirements to install laravel.

LAMP should be Installed
PHP >= 5.6.4
OpenSSL PHP Extension
PDO PHP Extension
Mbstring PHP Extension
Tokenizer PHP Extension

To upgrade php version, follow this link.

You can find out if this PHP module is installed or not by looking at the list that is produced by this command.

$ php -m

Those are not installed, install it by applying below given command.

$ sudo apt-get install php-mbstring

You can check it though phpinfo(); function

Laravel use composer to install dependencies. So, we need to install composer first.

$ sudo apt-get update
$ sudo apt-get install curl php5-cli git
$ curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

To test installation of composer, run composer.

$ composer

However, if you want to install it in your local project directory.

$ cd /var/www/html/
$ curl -sS https://getcomposer.org/installer | php

After installation of composer, follow below given steps to install laravel.

$ cd /var/www/html
$ git clone https://github.com/laravel/laravel.git
$ cd /var/www/html/laravel
$ sudo composer install

If above given command, produce error like this.

Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
– phpunit/phpunit 4.8.9 requires ext-dom * -> the requested PHP extension dom is missing from your system.

Perform below given steps.

$ sudo apt-get install php-xml
$ sudo apt-get install php7.0-xml

Now set the 32 bit long random number encryption key, which used by the Illuminate encrypter service.

$ php artisan key:generate

Application key [cdfnvjfnvjkenfnkjnekjcnjkdnvknf] set successfully.

Edit config/app.php configuration file and update above generated application key as followings. Also make sure cipher is set properly.

'key' => env('APP_KEY', 'uOHTNu3Au1Kt7Uloyr2Py9blU0J5XQ75'),

‘cipher’ => ‘AES-256-CBC’,

Don’t forget to give permissions.

$ chown -R www-data.www-data /var/www/html/laravel
$ chmod -R 755 /var/www/html/laravel
$ chmod -R 777 /var/www/html/laravel/app/storage

You are done with laravel installation, to run the website, ping your browser with below given URL.

http://localhost/laravel/public

To Create apache virtual host.

Add Virtual Host in your Apache configuration file to access Laravel framework from web browser.

vim /etc/apache2/sites-available/laravel.example.com.conf

<VirtualHost *:80>

ServerName laravel.com
DocumentRoot /var/www/html/laravel/public

<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/html/laravel>
AllowOverride All
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Run the command to enable laravel website and restart apache.

$ a2ensite laravel.example.com
$ sudo service apache2 reload

Now you can browse your laravel from this URL(http://laravel.example.com)

Cheers!

Upgrade PHP version in Ubuntu 14.04 LTS

To run new applications, like laravel, we need to upgrade our system. so, to update php version, follow below given steps.

  • sudo apt-get dist-upgrade
  • sudo LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
  • sudo apt-get update
  • sudo apt-get install php7.0 #for php 7
  • sudo apt-get install php5.6 #for php 5.6
  • sudo apt-get install php-xdebug php-apcu
  • php -v (to see the new version installed in your system)

Thanks.