How to install uuid extension in php
How to install the uuid extension in php: First, go to the PECL official website to download the php uuid extension; then install the dependent libraries; then use the phpize command to prepare the compilation environment for the PHP extension library; and finally install it through the install command.
The operating environment of this article: Ubuntu1804 system, php7.2 version, DELL G3 computer
PHP uses uuid
Environment
Ubuntu1804 php7.2 nginx
Preparation
Go to the PECL official website (https://pecl.php.net/package/uuid) to download the latest php uuid extension:
For example, uuid-1.1.0 version
$ wget https://pecl.php.net/get/uuid-1.1.0.tgz
Install the dependent library
The most important component of uuid is the machine code, most of which are the network card MAC address. PHP cannot obtain the machine code, so the code cannot be used directly to generate a uuid
Under ubuntu this package is uuid-dev, other platforms are similar
$ sudo apt-get install uuid-dev
Source code compilation and installation
- Unzip the package
$ tar -zxvf uuid-1.1.0.tgz
- Enter the root directory of the package
$ cd uuid-1.1.0/
- Initialization
$ phpize7.2
phpize command is used to prepare PHP The compilation environment of the extension library.
Generally in the bin directory, multiple versions of PHP find their corresponding phpize, such as /bin/phpize7.2
- Configuration
$ ./configure --with-php-config=/usr/bin/php-config7.2
php-config is a simple command line script used to obtain information about the installed PHP configuration
- Installation
$ sudo make $ sudo make test $ sudo make install
The file generated after successful installation is usually modules/××.so
Libraries have been installed in: /home/vagrant/uuid-1.1.0/modules
or
Installing shared extensions: /usr/lib/php/20170718/
in the current directory. If the extension .so file is not automatically added to the extension directory (you can view the extension_dir directory through phpinfo, which is the "/usr/lib/php/20170718/" above), you need to manually copy
$ sudo cp /home/vagrant/uuid-1.1.0/modules/uuid.so /usr/lib/php/20170718/
Configuration extension
We just installed the extensions before, but the specific extensions introduced in cli and fpm modes generally need to be configured separately
- Add the uuid extension to the corresponding configuration file
1. The old way of adding is usually to add a line directly to the php.ini file: extension=uuid.so;
2. The new version is easier to manage and is usually /etc/php/php7.2/mods- availableAdd the uuid.ini file and add a line extension=uuid.so;
3. Add it to the fpm and cli configuration
$ sudo ln -s /etc/php/7.2/mods-available/uuid.ini /etc/php/7.2/fpm/conf.d/uuid.ini $ sudo ln -s /etc/php/7.2/mods-available/uuid.ini /etc/php/7.2/cli/conf.d/uuid.ini
4. Restart fpm
sudo service php7.2-fpm reload
5. Check whether the installation is successful
- In cli mode
$ php -m |grep uuid
- In fpm mode
Through phpinfo () View
Use
<?php if (function_exists('uuid_create') === true) { echo uuid_create(), "<br>"; echo uuid_create(1); } else { echo 'uuid未安装'; }
output example:
33303096-b9c8-4e65-b4fd-3649e008b0e3 9f23c3b9-62c2-11ea-81b4-080027b68021
[Recommended learning: "PHP Video Tutorial"]
The above is the detailed content of How to install uuid extension in php. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

In this chapter, we are going to learn the following topics related to routing ?

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

Validator can be created by adding the following two lines in the controller.
