How To Install PHP Client For Elasticsearch On Windows
In this guide, it will be explained how to install PHP client Elasticsearch Windows OS. This is one of a list of tools found in the Elastic Stack. The steps below will walk the user through a complete setup for Windows. The PHP client will enhance the accuracy of retrieved data through Elasticsearch. Follow the simple process below to experience the dynamic power this software enables the user to wield in their queries.
>The Elasticsearch-PHP library is lightweight, easily installed via the Composer PHP dependency manager, and allows for one-to-one mapping wit
Note php client library for Elasticsearch has several requirements:
64-bit version of Windows 7 or 10 (Elastic does not support 32-bit architecture)
PHP 7 or higher is recommended for Composer and the PHP client
ext-jsonNative JSON Extension
Java and JDK 8 installed
The remaining dependencies are downloaded and installed by Composer automatically.
- Be mindful to match the version of Elasticsearch to the appropriate version of this library. Generally speaking, the major version number of the PHP library should match its respective Elasticsearch version (i.e. Only install Elasticsearch-PHP 4.x branch on a machine with Elasticsearch 4.x installed)
elasticsearch-phplibrary for Elasticsearch
Installing PHP in Windows
Windows 10 does not come with PHP installed.
Installing Java Development Kit (JDK) 8
Java 1.8 release series is recommended to be installed to run Elasticsearch. Only Elasticsearch v6.2, or newer, has JDK 9 support. h
Check the version installed by visiting the Java Control Panel that’s listed in the Start menu’s programs.
Inside the Java Control Panel, more information can be found by clicking the About tab to get:
- To select a Java version to run as the default, configure the
JAVA_HOMEenvironment variable. Just right click
My Computerand select
Properties. Once there, click on the
Advancedtab, and select the
Environment Variablesto edit the
JAVA_HOMEvariable to point at the JDK software location, for example:
C:\Program Files\Java\jdk1.X.X(make sure to replace
Xwith the proper version number for the installed JDK).
Installing Composer from GUI (Graphic-User-Interface)
Download the installer file via Composer’s Download page
Run the installer by double clicking the
The setup window will appear, just click next
Specify PHP 7 executable that Composer will use for command-line. Navigate to the
php.exefile in the directory (for example:
- If using proxy server, then check the option, otherwise just click next > to continue.
- Next setup window will display the installation setting(s) created from the previous steps. Click “Install” to continue.
- The Composer installer will initiate the installation process and will download related components.
- The installer will inform the user that the
Windows Environmenthas been changed. This enables composer to now be run via command prompt.
Below are the changes that Composer made to the system environment.
In the User Variables section the
PATHvariable can be set with the location value of Composer’s binary file. The path should be inthe
vendordirectory, like in this example:
“System Variables” section: PATH variable with a location value of
To acknowledge that the installation is now completed click finish.
Test Composer in command prompt by typing:
_>_Note! It is possible that nothing needs to be downloaded: If on Windows 10, version 1803 or later, the OS ships with a copy of curl that has already been set up and is ready to be used. If Git is installed (if Git was downloaded at git-scm.com, then yes), curl.exe is what it is under:
Add what is above to PATH.
The right package for windows build will have to be downloaded through curl’s website.
locate curl.exe under
bin\of the downloaded package.
Give the curl a folder within the preferred location in the hard drive.
Put the curl.exe under that folder and be sure to never move it or its content.
Ensure that curl is available from anywhere using the command line with the following steps.
On the windows system start menu, type
Notice the search result
" Edit system environment variables"then select it.
A System Properties window will open, then click the
"Environment Variables"button found at the bottom border of the window.
"System Variables"then click
"Add"button located on the right aside panel and paste the location in the folder path where the curl lives(i.e C:url).
Install Composer Via Command Line
elasticsearch/elasticsearch as a dependency in the project’s
composer.json file (change version to match installation):
Download and install Composer:
Require Autoloader in Composer:
Composer also can prepare an autoload file that is capable of handling all classes in any library it downloads. To make use of it, simply add the line below to the code’s bootstrap process:
$client = ClientBuilder::create()->build();
In this article, the basic elements of a successful install for PHP client are detailed. Above, the reader will find other pointers and helpful links to assist during the setup. Supporting documents can also be found linked to throughout the preceding instructions. If more in-depth information is required, the manufacturer can accommodate on their website. Before looking somewhere else for help, try some of the other guides found here or at one of the sources linked to below.
Pilot the ObjectRocket Platform Free!
Try Fully-Managed CockroachDB, Elasticsearch, MongoDB, PostgreSQL (Beta) or Redis.Get Started