PHPackages                             coxlr/laravel-natural-language - 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. [API Development](/categories/api)
4. /
5. coxlr/laravel-natural-language

ActiveLibrary[API Development](/categories/api)

coxlr/laravel-natural-language
==============================

Laravel package for the Google Natural language API

1.1.3(1mo ago)01.5k↓33.3%[3 PRs](https://github.com/coxlr/laravel-natural-language/pulls)MITPHPPHP ^8.1CI passing

Since Mar 27Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/coxlr/laravel-natural-language)[ Packagist](https://packagist.org/packages/coxlr/laravel-natural-language)[ Docs](https://github.com/coxlr/laravel-natural-language)[ RSS](/packages/coxlr-laravel-natural-language/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (13)Versions (10)Used By (0)

A Laravel package for the Google Natural language API
=====================================================

[](#a-laravel-package-for-the-google-natural-language-api)

[![Latest Version](https://camo.githubusercontent.com/c27961a543da6de226952ced79cc08e8c2c1d0277f2d0f44f1b013574a9c023b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f636f786c722f6c61726176656c2d6e61747572616c2d6c616e67756167652e7376673f7374796c653d666c61742d726f756e646564)](https://github.com/coxlr/laravel-natural-language/releases)[![Tests](https://github.com/coxlr/laravel-natural-language/actions/workflows/run-tests.yml/badge.svg)](https://github.com/coxlr/laravel-natural-language/actions/workflows/run-tests.yml)[![Total Downloads](https://camo.githubusercontent.com/3931e519a839c0deef6282bdd3a2e8ae0997a790b5f5350000ea49af6d279752/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636f786c722f6c61726176656c2d6e61747572616c2d6c616e67756167652e7376673f7374796c653d666c61742d726f756e64656426636f6c6f72423d627269676874677265656e)](https://packagist.org/packages/coxlr/laravel-natural-language)

This package makes using the Google Natural API in your laravel app a breeze with minimum to no configuration, clean syntax and a consistent package API. All methods accept a string and return an array: [Docs below.](https://github.com/Coxlr/laravel-natural-language/#how-to-use)

It builds upon [JoggApp/laravel-natural-language](https://github.com/JoggApp/laravel-natural-language), a package initially developed by [Harish Toshniwal](https://github.com/introwit) which is no longer activly maintained.

[![natural](https://user-images.githubusercontent.com/11228182/46806140-765d4000-cd84-11e8-9d88-e71338d53376.png)](https://user-images.githubusercontent.com/11228182/46806140-765d4000-cd84-11e8-9d88-e71338d53376.png)

Installation
------------

[](#installation)

This package requires PHP 8.1 and Laravel 10 or higher.

You can install this package via composer using this command:

```
composer require coxlr/laravel-natural-language
```

- The package will automatically register itself.
- You can find documentation on how to set up the project and get the necessary configurations from the Google Cloud Platform console in a step by step detailed manner [here.](https://github.com/Coxlr/laravel-natural-language/blob/master/google.md)
- You can publish the config file using the following command:

```
php artisan vendor:publish --provider="Coxlr\NaturalLanguage\NaturalLanguageServiceProvider"
```

This will create the package's config file called `naturallanguage.php` in the `config` directory. These are the contents of the published config file:

```
return [
    /*
    |--------------------------------------------------------------------------
    | The id of project created in the Google Cloud Platform console.
    |--------------------------------------------------------------------------
    */
    'project_id' => env('NATURAL_LANGUAGE_PROJECT_ID', 'sample-12345'),

    /*
    |--------------------------------------------------------------------------
    | Path to the json file containing the authentication credentials.
    |--------------------------------------------------------------------------
    */
    'key_file_path' => base_path('composer.json'),
];
```

Usage
-----

[](#usage)

After setting up the config file values you are all set to use the following methods:

- Detect the Sentiment: Accepts a string and returns an array.

```
NaturalLanguage::sentiment(string $text): array
```

- Detect the Entities: Accepts a string and returns an array.

```
NaturalLanguage::entities(string $text): array
```

- Detect the Sentiment per-entity basis: Accepts a string and returns an array.

```
NaturalLanguage::entitySentiment(string $text): array
```

- Detect the syntax: Accepts a string and returns an array.

```
NaturalLanguage::syntax(string $text): array
```

- Detect the categories: Accepts a string and returns an array.

```
NaturalLanguage::categories(string $text): array
```

- Annotate text: Accepts a string and an optional `features` array &amp; returns an array.

```
NaturalLanguage::annotateText(string $text, array $features = ['sentiment', 'syntax']): array
```

Testing
-------

[](#testing)

You can run the tests with:

```
composer test
```

Changelog
---------

[](#changelog)

Please see the [CHANGELOG](CHANGELOG.md) for more information about what has changed recently.

Security
--------

[](#security)

If you discover any security related issues, please email them to  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Lee Cox](https://github.com/coxlr)
- [Harish Toshniwal](https://github.com/introwit)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see the [License File](LICENSE.txt) for more information.

###  Health Score

45

—

FairBetter than 92% of packages

Maintenance85

Actively maintained with recent releases

Popularity19

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 53.8% 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.

###  Release Activity

Cadence

Every ~182 days

Total

5

Last Release

49d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8451762?v=4)[Lee](/maintainers/coxlr)[@coxlr](https://github.com/coxlr)

---

Top Contributors

[![coxlr](https://avatars.githubusercontent.com/u/8451762?v=4)](https://github.com/coxlr "coxlr (14 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (6 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (6 commits)")

---

Tags

apilaravelgooglepackagenatural-languagecoxlr

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/coxlr-laravel-natural-language/health.svg)

```
[![Health](https://phpackages.com/badges/coxlr-laravel-natural-language/health.svg)](https://phpackages.com/packages/coxlr-laravel-natural-language)
```

###  Alternatives

[joisarjignesh/bigbluebutton

BigBlueButton Server API Library for Laravel

162145.5k1](/packages/joisarjignesh-bigbluebutton)[mbarwick83/shorty

Google Url Shortener API Package for Laravel 5.1

31204.9k](/packages/mbarwick83-shorty)[gregoriohc/laravel-trello

A Laravel wrapper and facade package for the Trello API

3366.8k2](/packages/gregoriohc-laravel-trello)[vinelab/api-manager

Laravel API Manager Package - beatify and unify your responses with the least effort possible.

392.1k](/packages/vinelab-api-manager)

PHPackages © 2026

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