Tag Archives: php

How to run PHP in Docker Container

If you ended up here you probably want a fast solution to get your PHP scripts running without installing Apache in your host PC.

Well, there you go (docker-compose.yml):

version: '3.8'
        container_name: php-apache
        image: php:8.0-apache
            - ./source/code:/var/www/html/
            - 8000:80

Run docker-compose up and voila 😀

How to generate X-WSSE Token using PHP

Learn how to generate X-WSSE Token and how to authorize requests using X-WSSE header authentication.

If you’re not familiar with X-WSSE Token Authentication and why you should use it, go ahead and read this article that contains the basics of this type of authentication.

In this article I’ll describe how to generate a X-WSSE Token using PHP.

function getWsseHeader($username, $secret) {
    $nonce = md5(rand());
    $created  = date('c');
    $digest   = base64_encode(hash('sha256', $nonce . $created . $secret, false));
    $wsseHeader = sprintf(
        'UsernameToken Username="%s", PasswordDigest="%s", Nonce="%s", Created="%s"',
    return $wsseHeader;
$xwsse = getWsseHeader("CLIENT_ID", "CLIENT_SECRET");
echo $xwsse;

That’s it. Check my other X-WSSE Articles and learn how to generate the token using other programming languages.

How to create a basic Google Maps plugin for WordPress

There might be some WordPress plugins out there that could be used to add Google map to posts and pages. Still I didn’t find it necessary to install one when creating it is fun and easy.

Adding the final plugin to a post/page will be done using shortcode.

First of all you must create the plugin directory in wp-content/plugins/plugin_name.

Add two files here, the first an empty index.php and the second plugin_name.php

In order to be able to activate this plugin some basic details need to be added at the beginning:

 * Plugin Name: Custom Google Maps
 * Plugin URI: http://catalinmunteanu.com
 * Description: Create Google Map element using a location query
 * Version: 1.0.0
 * Author: Catalin Munteanu
 * Author URI: http://catalinmunteanu.com

Then we must create a function that will process this plugin’s shortcode:


function google_map_print($attrs, $content=null) {
    $item = shortcode_atts(
            'location' => null

    $result = '<div>';
        $result .= '<iframe
            scrolling="no" marginheight="0" marginwidth="0"
            frameborder="0" style="border:0"
    $result .= '</div>';
    return $result;


add_shortcode('google-map', 'google_map_print');


That’s all. After you activate the plugin you can add it in your posts and pages using the shortcode:

[google-map location="Bucharest"]


[custom-google-map location=”Bucharest”]