PHP functions/extensions in JavaScript with Locutus
Functions and extensions in programming languages are very helpful at the time we need to get a result in less amount of time or to write less code to have our project optimised.
But when in your favourite programming/scripting language (JS in this case) you want to use some specific function but this function is only in PHP… well in that case Locutus is going to be your solution because they built JS functions that give the same result as a original PHP function (with some limitations).
For example, if you want to use the uniqid function in your Javascript project, you can do it by following these steps:
- Install the library
yarn install locutus
- Import the library
import uniqid from 'locutus/php/misc/uniqid'
- Use the library
const customId = uniqid()
All the extensions are very easy to follow and use and of course, very useful.