PHPackages                             coremad/core - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. coremad/core

ActiveLibrary

coremad/core
============

Core package for detecting user agent, device, and location

00PHP

Since Nov 23Pushed 1y ago1 watchersCompare

[ Source](https://github.com/ahmadjn/CoreMad)[ Packagist](https://packagist.org/packages/coremad/core)[ RSS](/packages/coremad-core/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

CoreMad
=======

[](#coremad)

CoreMad adalah package PHP yang menyediakan metode-metode mudah untuk:

- Deteksi Bot/Crawler
- Deteksi tipe perangkat (Mobile/Tablet/Computer)
- Deteksi negara berdasarkan IP address
- Deteksi parameter tracking (Google Ads, Facebook)

Persyaratan
-----------

[](#persyaratan)

- PHP 8.0 atau lebih tinggi
- Composer untuk instalasi
- Database MaxMind GeoIP2 (untuk deteksi negara)

Instalasi
---------

[](#instalasi)

Instalasi package menggunakan Composer:

```
# Instalasi versi stable
composer require coremad/core

# Atau instalasi dengan versi spesifik
composer require coremad/core:^1.0

# Atau instalasi versi dev
composer require coremad/core:dev-main
```

Fitur
-----

[](#fitur)

### 1. Deteksi Bot/Crawler

[](#1-deteksi-botcrawler)

- Menggunakan library `jaybizzle/crawler-detect`
- Dapat mendeteksi berbagai jenis bot dan crawler
- Mendapatkan nama bot jika terdeteksi

### 2. Deteksi Device

[](#2-deteksi-device)

- Menggunakan library `mobiledetect/mobiledetectlib`
- Deteksi smartphone, tablet, dan desktop
- Support berbagai user agent header

### 3. Deteksi Negara

[](#3-deteksi-negara)

- Menggunakan MaxMind GeoIP2 database
- Mendapatkan kode dan nama negara
- Mendapatkan kode dan nama benua
- Validasi format IP address (IPv4 &amp; IPv6)

### 4. Deteksi Parameter Tracking

[](#4-deteksi-parameter-tracking)

- Google Ads Click ID (gclid)
- Facebook Click ID (fbclid)
- Google Ads Source (gad\_source)

Persiapan Database GeoIP
------------------------

[](#persiapan-database-geoip)

Untuk menggunakan fitur deteksi negara, Anda perlu:

1. Daftar akun di [MaxMind](https://www.maxmind.com/en/geolite2/signup)
2. Download database GeoLite2 Country dari MaxMind
3. Simpan file database (GeoLite2-Country.mmdb) di server Anda
4. Catat path ke file database untuk digunakan saat inisialisasi CoreMad

Penggunaan
----------

[](#penggunaan)

### Inisialisasi

[](#inisialisasi)

```
use CoreMad\Core\CoreMad;
// Tanpa deteksi negara
$coreMad = new CoreMad();
// Dengan deteksi negara (sertakan path ke database GeoIP)
$coreMad = new CoreMad('/path/to/GeoLite2-Country.mmdb');
```

### Deteksi Bot/Crawler

[](#deteksi-botcrawler)

```
// Cek apakah pengunjung adalah bot
if ($coreMad->isBot()) {
// Pengunjung adalah bot
$botName = $coreMad->getBotName();
echo "Bot terdeteksi: " . $botName;
} else {
echo "Pengunjung adalah manusia";
}
```

### Deteksi Perangkat

[](#deteksi-perangkat)

```
// Cek tipe perangkat
if ($coreMad->isMobile()) {
echo "Pengguna menggunakan smartphone";
} elseif ($coreMad->isTablet()) {
echo "Pengguna menggunakan tablet";
} elseif ($coreMad->isComputer()) {
echo "Pengguna menggunakan komputer desktop";
}
```

### Deteksi Negara

[](#deteksi-negara)

```
try {
// Deteksi negara berdasarkan IP
$countryInfo = $coreMad->getCountryFromIp('8.8.8.8');
if ($countryInfo) {
echo "Kode Negara: " . $countryInfo['country_code'] . "\n";
echo "Nama Negara: " . $countryInfo['country_name'] . "\n";
echo "Kode Benua: " . $countryInfo['continent_code'] . "\n";
echo "Nama Benua: " . $countryInfo['continent_name'];
} else {
echo "Informasi negara tidak ditemukan";
}
} catch (Exception $e) {
echo "Error: " . $e->getMessage();
}
```

### Deteksi Parameter Tracking

[](#deteksi-parameter-tracking)

Package ini juga dapat mendeteksi parameter tracking dari Google Ads dan Facebook:

```
// Cek Google Click ID (gclid)
if ($coreMad->hasGoogleClickId()) {
    echo "Google Click ID: " . $coreMad->getGoogleClickId();
}

// Cek Facebook Click ID (fbclid)
if ($coreMad->hasFacebookClickId()) {
    echo "Facebook Click ID: " . $coreMad->getFacebookClickId();
}

// Cek Google Ads Source (gad_source)
if ($coreMad->hasGoogleAdsSource()) {
    echo "Google Ads Source: " . $coreMad->getGoogleAdsSource();
}

// Dapatkan semua parameter tracking sekaligus
$trackingParams = $coreMad->getTrackingParams();
print_r($trackingParams);
/* Output:
[
    'gclid' => 'google_click_id_value',
    'fbclid' => 'facebook_click_id_value',
    'gad_source' => 'google_ads_source_value'
]
*/
```

Penanganan Error
----------------

[](#penanganan-error)

Package ini menggunakan exception untuk menangani error. Beberapa error yang mungkin terjadi:

1. Database GeoIP tidak ditemukan atau rusak:

```
try {
$coreMad = new CoreMad('/path/invalid/GeoLite2-Country.mmdb');
} catch (Exception $e) {
// Handle error
echo "Error: " . $e->getMessage();
}
```

2. IP address tidak valid atau tidak ditemukan:

```
try {
$countryInfo = $coreMad->getCountryFromIp('invalid.ip.address');
} catch (Exception $e) {
// Handle error
echo "Error: " . $e->getMessage();
}
```

Dependencies
------------

[](#dependencies)

Package ini menggunakan beberapa library pihak ketiga:

- [jaybizzle/crawler-detect](https://github.com/JayBizzle/Crawler-Detect) v1.2 - untuk deteksi bot
- [mobiledetect/mobiledetectlib](https://github.com/serbanghita/Mobile-Detect) v3.74 - untuk deteksi perangkat
- [geoip2/geoip2](https://github.com/maxmind/GeoIP2-php) v2.13 - untuk deteksi negara

Versioning
----------

[](#versioning)

Package ini menggunakan [Semantic Versioning](https://semver.org/):

- MAJOR version (X.0.0) - perubahan yang tidak backward compatible
- MINOR version (0.X.0) - penambahan fitur yang backward compatible
- PATCH version (0.0.X) - bug fixes yang backward compatible

Security
--------

[](#security)

Jika Anda menemukan masalah keamanan, mohon jangan buat issue publik. Silakan kirim email ke

Kontribusi
----------

[](#kontribusi)

Kontribusi selalu diterima! Berikut langkah-langkahnya:

1. Fork repository
2. Buat branch baru (`git checkout -b feature/AmazingFeature`)
3. Commit perubahan (`git commit -m 'Add some AmazingFeature'`)
4. Push ke branch (`git push origin feature/AmazingFeature`)
5. Buat Pull Request

Lisensi
-------

[](#lisensi)

Package ini dilisensikan di bawah [Lisensi MIT](LICENSE).

Author
------

[](#author)

- **Ahmad Jamaluddin**
- Email:
- GitHub: [ahmadjn](https://github.com/ahmadjn)

Support
-------

[](#support)

Jika Anda menemukan bug atau memiliki permintaan fitur:

1. Buat issue di GitHub repository
2. Kirim email ke
3. Submit pull request dengan perbaikan

Changelog
---------

[](#changelog)

### \[1.0.0\] - 2024-03-XX

[](#100---2024-03-xx)

- Initial release
- Fitur deteksi bot/crawler
- Fitur deteksi device
- Fitur deteksi negara
- Fitur deteksi parameter tracking

Development
-----------

[](#development)

### Auto-update Packagist

[](#auto-update-packagist)

Package ini menggunakan GitHub Webhook untuk auto-update di Packagist setiap kali ada push ke repository.

Untuk release versi baru:

1. Update versi di `composer.json`
2. Commit perubahan

```
git add composer.json
git commit -m "Bump version to X.Y.Z"
```

3. Create dan push tag

```
git tag vX.Y.Z
git push origin vX.Y.Z
```

4. Package akan otomatis terupdate di Packagist

> **Catatan**: Webhook sudah dikonfigurasi untuk auto-update saat ada push ke repository.

###  Health Score

13

—

LowBetter than 1% of packages

Maintenance30

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity16

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/66138ea3bb590b9912a2ceb6efb6bd8f6b9bd55a2514d85a88df248852d27915?d=identicon)[ahmadjn](/maintainers/ahmadjn)

---

Top Contributors

[![ahmadjn](https://avatars.githubusercontent.com/u/59970179?v=4)](https://github.com/ahmadjn "ahmadjn (11 commits)")

### Embed Badge

![Health badge](/badges/coremad-core/health.svg)

```
[![Health](https://phpackages.com/badges/coremad-core/health.svg)](https://phpackages.com/packages/coremad-core)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
