Download the PHP package indatus/ranger without Composer

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

Ranger

The Api Base Controller is a Laravel package that allows you to get your api up and running fast. The process of creating an api can be very tedious, especially when you consider how validation, errors, and response codes will be handled. Instead of this tedium, install ranger, extend the ApiBaseController (see examples below), and that's it. If you feel that you want this more tailored to your needs, Ranger follows the Open/Closed principle so extending the core components is really easy.

Ranger allows for:

Searching
Eager Loading
Joins
Left Joins

Ranger also has support for both Nested and Non-nested resources. It handles Json and HTML content types but can easily be extended for other content types as well.


README Contents

  • Installation

    • Configure in Laravel
  • Configuration Options

  • Security

  • Examples

    • Non-nested resource Controller
    • Nested resource Controller
    • Nested Resource Routes
    • GET Collection Example
    • GET Instance Example
    • POST Request Example
    • PUT Request Example
    • DELETE Request Example
    • Eager load example
    • Join example
    • Search example
  • How to Solve Basic Problems

Installation

Install With Composer

You can install the library via Composer by adding the following line to the require block of your composer.json file:

`

Next run composer install

Back To Top

Configure in Laravel

Currently Ranger works Only with the Laravel framework. However, we do have plans to make this package framework agnostic.

To publish this config to app/config/packages/indatus/ranger folder, you need to run the following:

`

The final step is to add the service provider. Open app/config/app.php, and add a new item to the providers array.

'Indatus\Ranger\RangerServiceProvider'

That's all. Now you can start using Ranger. Checkout the Examples below.


Back To Top

Configuration Options

Ranger Settings (ranger.php)

Ranger comes with a few configuration options. You can set the content type of the results in your api. You can also select whether you want paginated results or return the entire collection. If you want pagination, you can set the per_page value.

Setting Default Description
pagination.per_page null On collections, you get to decide whether you want the results paginated. A null value will return all of the results

Supported Options: any integer will return a paginated result ie) 25 for this config setting will return a paginated collection of 25.
content_type.default json Set the content type of the data. By default, it's json, but you can set this to html.

If you would like the header to dictate what the content type to be, just set this option to null and make sure the client embeds the content type in the header ie) 'Accept' = 'application/json'

Supported Options: html

NOTE: The std_search options in this config are for future versions. Change them at your own risk, but I recommend leaving them alone for now. As we expand the searching functionality a bit, these values will be more configurable in future releases.

All of this functionality can be achieved by just extending the ApiBaseController class.

I'm assuming that you have taken the appropriate steps in setting up Eloquent models along with migrations.

The examples in this documentation are directly from the example app, in the repo above. Two entities are created User and Account.

Back To Top

Examples

Non-Nested Resource Example

Here's an example of a non-nested resource



Back To Top

Next, let's have a look at the routes file in app/routes.php



Throughout this readme, I will assume the url of your code will be
http://www.example.com

http://www.example.com/v1/users GET Request will return a collection of all users in json format ie):

`

Back To Top

http://www.example.com/v1/users/1 GET request will return a single user instance in json format ie):

`

Back To Top

http://www.example.com/v1/users POST request will add a user to the database and return:

`

Back To Top

http://www.example.com/v1/users/1 DELETE request will delete a single user instance and return the following:

`

Back To Top

http://www.example.com/v1/users/1 PUT request will update a single user instance and return the following:

`

Back To Top

http://www.example.com/v1/users?eagerLoads[0]=accounts GET request will return all users along with their accounts:

`

Back To Top

http://www.example.com/v1/users?joins[0]=accounts:users.id=accounts.user_id GET request will return all users along with their accounts joined:

`

Back To Top

SEARCHING: http://www.example.com/v1/users?searchParams[property]=name&searchParams[operator]=like&searchParams[value]=%Ch%

`


Back To Top

Nested Resource Example

Here's an example of a nested resource controller



Back To Top

Next, let's have a look at the routes file in app/routes.php. Nested resources are a little different



Now you will be able to access the data in the same manner as the non nested resource above. The only difference is the urls will be the following:




Back To Top

Security

SECURITY: Out of the box, we do not offer authentication to perform these operations. Authentication should be up to the developer to implement because it's so specific to the application. We feel, that we needed to make a statement about security because without it, anyone will have access to data on your api.

Keep in mind, this package takes away a lot of the pain points in developing an api, and you would have to write your own authentication on top of reinventing the api wheel.

We are working on a sample app that will show you basic authentication.


How to Solve Basic Problems

Problem:

You are getting an InvalidInputException even though you sure your http request is working.

Solution

If you are trying to hit one of the api endpoints described above ie) example.com/api/users and get an InvalidInputException, this is most likely due to how you have your apache or nginx config setup.

If you are using apache, make sure that your .htaccess file looks like the following:

If you are using ngnix please refer to the following:



All versions of ranger with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
illuminate/support Version 4.1.*
illuminate/container Version 4.1.*@dev
illuminate/database Version 4.1.*@dev
illuminate/view Version 4.1.*@dev
illuminate/routing Version 4.1.*@dev
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 indatus/ranger contains the following files

Loading the files please wait ....