Scris pe

MyComposer: IP

Since I discovered Composer for PHP the whole way of how I write code has changed. I try to use Composer as much as I can. And I always wanted to have my own packages. The first one I will present you now is filipac/ip. In a few projects that  I work on often I need to get the visitor’s IP address. So I decided to make a Composer package to help me in all my projects and to help the PHP community.

How to install filipac/ip?

If you already use Composer in your project add the following code in composer.json, if not create a file called composer.json and add the following code:

"require": {
        "filipac/ip": "~1.0"

After that run composer update command. I assume you already know how to use Composer, if not read here a quick start.

After that in your script you can get the visitor’s ip like that:

include 'vendor/autoload.php';
use Filipac\Ip;
$ip = Ip::get();
echo "Hello, your ip is {$ip}";

I hope this helps you and this plugin is useful. If you want to improve it, fork the Github project, make changes, commit and create a merge request.

Thank you.

1 comentarii la acest articol

Lasă un răspuns

Adresa ta de email nu va fi publicată. Câmpurile obligatorii sunt marcate cu *

Acest site folosește Akismet pentru a reduce spamul. Află cum sunt procesate datele comentariilor tale.

Copyright © 2024 toate drepturile
nu sunt
rezervate. Faceti ce vreti, e o tara libera.
Cred ca nu mai are rost sa zic, dar tema e facuta de mine cu Tailwind CSS. Gasesti codul sursa aici.
Inca folosesc WordpPess 🧡. Tema e insa custom Laravel 😎.