Download the PHP package moesif/moesif-laravel without Composer

On this page you can find all versions of the php package moesif/moesif-laravel. 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 moesif-laravel

Moesif Laravel Middlware

Built For Latest Version Total Downloads Software License Source Code

Source Code on GitHub

Middleware for PHP Laravel (> 5.1) to automatically log API Calls and sends to Moesif for API analytics and log analysis

Laravel 4.2

A Moesif SDK is available for Laravel 4.2. Credit for creating this goes to jonnypickett.

How to install

Via Composer

or add 'moesif/moesif-laravel' to your composer.json file accordingly.

How to use

Add Service Provider

Add to Middleware

If website root is your API, add to the root level:

If you only want to add tracking for APIs under specific route group, add to your route group, but be sure to remove from the global middleware stack from above global list.

To track only certain routes, use route specific middleware setup.

Publish the package config file

Setup config

Edit config/moesif.php file.

Your Moesif Application Id can be found in the Moesif Portal. After signing up for a Moesif account, your Moesif Application Id will be displayed during the onboarding steps.

You can always find your Moesif Application Id at any time by logging into the Moesif Portal, click on the top right menu, and then clicking Installation.

For other configuration options, see below.

Configuration options

To support Laravel configuration caching, some configuration options have moved into a separate config class for v2. See Migration Guide v1.x.x to v2.x.x

You can define Moesif configuration options in the config/moesif.php file.

applicationId

Type: String Required, a string that identifies your application.

disableForking

Type: Boolean Optional, If true, this will disable forking. For the best performance, the SDK forks a process to send events by default. However, this requires your PHP environment to not have exec disabled via disable_functions.

debug

Type: Boolean Optional, If true, will print debug messages using Illuminate\Support\Facades\Log

logBody

Type: Boolean Optional, Default true, Set to false to remove logging request and response body to Moesif.

apiVersion

Type: String Optional, a string to specify an API Version such as 1.0.1, allowing easier filters.

configClass

Type: String Optional, a string for the full path (including namespaces) to a class containing additional functions. The class can reside in any namespace, as long as the full namespace is provided.

example:

Configuration class

Because configuration hooks and functions cannot be placed in the config/moesif.php file, these reside in a PHP class that you create. Set the path to this class using the configClass option. You can define any of the following hooks:

identifyUserId

Type: ($request, $response) => String Optional, a function that takes a $request and $response and return a string for userId. Moesif automatically obtains end userId via $request->user()['id'], In case you use a non standard way of injecting user into $request or want to override userId, you can do so with identifyUserId.

identifyCompanyId

Type: ($request, $response) => String Optional, a function that takes a $request and $response and return a string for companyId.

identifySessionId

Type: ($request, $response) => String Optional, a function that takes a $request and $response and return a string for sessionId. Moesif automatically sessionizes by processing at your data, but you can override this via identifySessionId if you're not happy with the results.

getMetadata

Type: ($request, $response) => Associative Array Optional, a function that takes a $request and $response and returns $metdata which is an associative array representation of JSON.

maskRequestHeaders

Type: $headers => $headers Optional, a function that takes a $headers, which is an associative array, and returns an associative array with your sensitive headers removed/masked.

maskRequestBody

Type: $body => $body Optional, a function that takes a $body, which is an associative array representation of JSON, and returns an associative array with any information removed.

maskResponseHeaders

Type: $headers => $headers Optional, same as above, but for Responses.

maskResponseBody

Type: $body => $body Optional, same as above, but for Responses.

skip

Type: ($request, $response) => String Optional, a function that takes a $request and $response and returns true if this API call should be not be sent to Moesif.

Example config class

Update a Single User

Create or update a user profile in Moesif. The metadata field can be any customer demographic or other info you want to store. Only the user_id field is required.

The metadata field can be any custom data you want to set on the user. The user_id field is required.

Update Users in Batch

Similar to updateUser, but used to update a list of users in one batch. Only the user_id field is required.

The metadata field can be any custom data you want to set on the user. The user_id field is required.

Update a Single Company

Create or update a company profile in Moesif. The metadata field can be any company demographic or other info you want to store. Only the company_id field is required.

The metadata field can be any custom data you want to set on the company. The company_id field is required.

Update Companies in Batch

Similar to update_company, but used to update a list of companies in one batch. Only the company_id field is required.

The metadata field can be any custom data you want to set on the company. The company_id field is required.

Credits for Moesif Laravel SDK

Additional Tips:

In case you've exec() as a disabled function, you could set configuration option disableForking to true to send data to Moesif using curl PHP extension.

Troubleshooting

exec() must exist/exec() must be enabled

By default, Moesif forks a process to log API calls in an asynchronous method, which requires your PHP environment to have exec() enabled. For highest performance, the recommended fix is to ensure exec() is enabled for your hosting environment:

If you cannot enable exec (such as for shared hosting environments), you can disable forking by adding the following to your moesif.php.

The PHP JSON extension is required.

Make sure you install PHP with the JSON Extension enabled More Info.

The PHP cURL extension is required

This error happens when you disabled forking and you do not have the cURL PHP extension enabled. The recommended fix is to enable forking by setting disableForking to false in your moesif.php. Otherwise, ensure you have enabled the PHP CURL extension. More info.

No events show up in Moesif

Because Moesif forks a process, you may not see all errors from the child process. A common case for event not showing up is due to an incorrect application id. To see debug logs, you can add the following to your moesif.php:

Test Laravel App with Moesif Integrated

Moesif Laravel Tests

An Example Laravel App with Moesif Integrated

Moesif Laravel Example

Be sure to update cache after changing config:

If you enabled config cache, after you update the configuration, please be sure to run php artisan config:cache again to ensure configuration is updated.

Other integrations

To view more documentation on integration options, please visit the Integration Options Documentation.

Migration Guide v1.x.x to v2.x.x

v2.x.x now supports Laravel config caching. However, config:cache does not allow function closures in config files (See issue on github) so the SDK configuration has changed in v2.x.x. To migrate, you will need to move any functions from your config/moesif.php into a separate class such as CustomMoesifConfig. Then, reference this class using configClass.

For example, if you had these previously:

In V2.X.X, you would do this:


All versions of moesif-laravel with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
ext-curl Version *
ext-json Version *
ext-mbstring Version *
mashape/unirest-php Version ~3.0.1
apimatic/jsonmapper Version ~1.0.0
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 moesif/moesif-laravel contains the following files

Loading the files please wait ....