Download the PHP package ranvis/mecab without Composer

On this page you can find all versions of the php package ranvis/mecab. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package mecab

PHP-MeCab-FFI

MeCab binding using FFI.

License

BSD 2-Clause License

This library contains a part of MeCab interface definitions, which is licensed under BSD 3-Clause License as stated there.

Installation

First make sure you have enabled FFI extension, which is bundled with PHP. Then execute the Composer command:

composer require "ranvis/mecab:^0.3"

Make sure you have installed MeCab 0.996 (or later compatible version) on your system along with the dictionary. On Windows and some Linux distros, there should be a pre-built package.

Last but not least, if you are going to use the library from non-CLI environment such as web server, ffi.enable=true instead of the restricted default ffi.enable=preload must be set in the system INI configuration used by the SAPI.

Example Usage

Preloading Dynamic Library

Loading dynamic library using script via FFI extension has a small overhead compared with native PHP extension. This can be mitigated by using FFI's preload feature. With preloading, daemon-like SAPI such as FPM can preprocess initialization of the library and reuse it afterwards.

Preload using ffi.preload

To make use of this, we need to generate a header file for MeCab once. Run bundled gen_mecab_preloader command with the destination (and MeCab library name/path).

Then set ffi.preload ini value to point to the file. (The header file may have to be regenerated in case this library is largely updated.)

Now to see if it works, we use CLI to run the following script. Notice that MeCab\Env is now instantiated with the MeCab\Env::fromScope() static method instead of a new operator, to take advantage of preloading.

If your PHP is running in daemon-like style like FPM, restart the daemon process to take effect.

Preload using opcache.preload

Note: OPcache's preloading is not supported in Windows. (gh#4999)

Another way of preloading is to use OPcache's one. OPcache also has a feature to preload classes that you use often. FFI can be initialized during this step as well, provided that opcache.preload_user is not set, or set as the current system user on PHP 8.3 and later. (Usually it is not set.)

In the PHP script specified in opcache.preload ini value, call MeCab\Env::preload() as follows:

And then on the actual script, call MeCab\Env::fromScope() to instantiate like the former example.

While this looks simpler than the former way, a header file will be silently created on the system's temporary directory everytime OPcache's preloading triggers; since FFI doesn't allow in-memory interface definitions for preloading as of PHP 8.3.


All versions of mecab with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0.0
ext-ffi Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ranvis/mecab contains the following files

Loading the files please wait ....