Installation

The library comes up with different options for installations. The easiest one is to get it from PECL (a repository for PHP Extensions):

pecl install ds

We can also download the source code and compile the library if we want. In order to do that, we just need to get the code from the GitHub repository and follow the git commands:

clone https://github.com/php-ds/extension "php-ds"
cd php-ds

# Build and install the extension
phpize
./configure
make
make install

# Clean up the build files
make clean
phpize --clean

If there is any dependency issue, we have to install this package as well:

sudo apt-get install git build-essential php7.0-dev

For Windows, the DLL is available to download from PECL site. For Mac OS users, Homebrew has support to install this extension:

brew install homebrew/php/php71-ds

Once the installation is done, we have to add the extension to our primary php.ini file:

extension=ds.so  #(php_ds.dll for windows)

If the extension is properly added, all pre-built classes will be available through global DS namespace.

Now, let's get into details for pre-built DS classes from this extension. We will start with the base of all classes, the collection interface.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset