Download the PHP package spinen/n-central-php-rest-client without Composer

On this page you can find all versions of the php package spinen/n-central-php-rest-client. 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 n-central-php-rest-client

NOTE: This is VERY early. This is changing as N-central updates their API & as we get a better understanding of the API. There are broken tests & some missing code, but we will firm this up over the next few weeks.

SPINEN's N-central PHP Client

Latest Stable Version Latest Unstable Version Total Downloads License

PHP package to interface with N-able's N-central Server. We strongly encourage you to review N-central's API docs to get a feel for what this package can do, as we are just wrapping their API. We have based the majority of this code from our Halo PHP Client.

We solely use Laravel for our applications, so this package is written with Laravel in mind. We have tried to make it work outside of Laravel. If there is a request from the community to split this package into 2 parts, then we will consider doing that work.

Build Status

Branch Status Coverage Code Quality
Develop Build Status Code Coverage Scrutinizer Code Quality
Master Build Status Code Coverage Scrutinizer Code Quality

Table of Contents

Installation

Install N-central PHP Package via Composer:

Laravel Setup

  1. Add the appropriate values to your file

    Keys

  2. [Optional] If you would like to use the client with API calls per user in your application, you will need to make your User object implement includes the Spinen\Ncentral\Concerns\HasNcentral trait which will allow it to access the Client as an attribute like this: $user->ncentral

  3. [Optional] Publish config & migration

    Config

    A configuration file named ncentral.php can be published to config/ by running...

    Migration

    Migrations files can be published by running...

    You'll need the migration to set the N-central API token on your User model.

Generic PHP Setup

  1. You need to build up an array of configs to pass into the N-central object. You review the ncentral.php file in the configs directory. All of the properties are documented in the file.

  2. Depending on your needs, you can either work with the N-central client or the Builder

    To get a Spinen\Ncentral\Api\Client instance for Client Credentials...

    To get a Spinen\Ncentral\Support\Builder instance...

    If using the ncentral property from the user model, it the will work exactly like all of the examples below where $builder is used.

Authentication

N-central uses a JWT token for a user that is limited to only API calls. This prevents ths account from being able to log directly into the application. To obtain the "N-central User-API Token (JWT)", visit the N-central UI. Then navigate to Administration → User Management → Users → Click on user → API Access → GENERATE JSON WEB TOKEN.

Usage

Supported Actions for Spinen\Ncentral\Api\Client

NOTE: This is the best way to get a token as it handles expiration

Using the Client

The Client is meant to emulate Laravel's models with Eloquent. When working with N-central resources, you can access properties and relationships just like you would in Laravel.

Models

The API responses are cast into models with the properties cast into the types as defined in the N-central API documentation. You can review the models in the src/ folder. There is a property named casts on each model that instructs the Client on how to cast the properties from the API response. If the casts property is empty, then the properties are not defined in the API docs, so an array is returned.

NOTE: The documented properties on the models are likely to get stale as N-central is in active development

Relationships

NOTE: Not yet setup

Some of the responses have links to the related resources. If a property has a relationship, you can call it as a method and the additional calls are automatically made & returned. The value is stored in place of the original data, so once it is loaded it is cached.

You may also call these relationships as attributes, and the Client will return a Collection for you (just like Eloquent).

Collections

Results are wrapped in a Spinen\Ncentral\Support\Collection, which extends Illuminate\Support\Collection, so you can use any of the collection helper methods documented Laravel Collection methods.

Filtering using "where"

You can do filters by using where on the models. The first parameter is the property being filtered. The second is optional, and is the value to filter the property. If it is left null, then is it true, so it becomes where('<property', true). All of these values are passed in the query string.

There are a few "helper" methods that are aliases to the where filter, to make the calls more expressive.

Limit records returned

You can call the take or limit methods (take is an alias to limit) on the builder to limit the records returned to the count parameter.

Pagination

Several of the endpoints support pagination. You can use simple pagination by chaining pagination with an optional size value to the builder. You can get a specific page with the page method that takes page number as a parameter. You can condense the call by passing pagination size as the second parameter to the page method.

More Examples

Open Items

Known Issues


All versions of n-central-php-rest-client with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-json Version *
guzzlehttp/guzzle Version ^7.0
laravel/framework Version ^9.19|^10|^11
nesbot/carbon Version ^2.62.1|^3
spinen/laravel-version Version ^1.5
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 spinen/n-central-php-rest-client contains the following files

Loading the files please wait ....