Tag Archives: PHP

Drupal 8 – Create a node through RESTful Web Service @ 1

In the previous posts, we have gone through some examples about working with Drupal 8 RESTful web service.


We can also add node to Drupal through web service. But as i mentioned before, the RESTful feature is not fully completed so we can only create a node with a title. Here is a example web service client in PHP using Guzzle.
Continue reading

Drupal 8 – Login in Guzzle Web Service Client @ 1

1. Get your PHP client ready by following my previous post.


2. Update your index.php as follow.

  require 'vendor/autoload.php';
  use Guzzle\Http\Client;
  use Guzzle\Plugin\Cookie\CookiePlugin;
  use Guzzle\Plugin\Cookie\CookieJar\ArrayCookieJar;

  $cookiePlugin = new CookiePlugin(new ArrayCookieJar());
  $client = new Client('http://drupal8.localhost.com');
  $request = $client->post('user', null, array(
    'name' => '<username>',
    'pass' => '<password>',
    'form_id' => 'user_login_form',
  $request->addHeader('Accept', 'application/json');

  $response = $request->send()->json();

  print '<pre>';
  print '</pre>';

Continue reading

Connect Drupal 8 RESTful Service with Guzzle PHP Web Service Client @ 1

Previously I have setup a a Drupal 8 which is RESTful ready.

Guzzle is a PHP HTTP client & framework for building RESTful web service clients. In this example, we would create a simple .php to fetch a node from Drupal 8.

1. Make sure you have the Composer installed. You can refer to my previous post.

Continue reading

Composer – Manage your PHP dependencies

Mess up with the PHP dependencies in different environments? Composer is a PHP dependency manager where all the dependencies information are stored in the JSON file called composer.json. Similar to the pom.xml if you are using Maven in Java.

This example is done on a Windows machine. You could refer to Composer website if you are using Mac or Linux.

1. Download and install the Composer as stated in the Composer website.
Continue reading