Download the PHP package vinceurag/simplyrest without Composer

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

SimplyREST

A micro-framework written in PHP that will help you build RESTful APIs.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

Some things that you need

Installing

Make sure is installed on your machine and the directory is in your $PATH so the executable can be located by your system.

Download the SimplyREST installer via composer

Initialize a new app

Verify that your web server and mysql is started.

Modify with your database details.

Test if it's working. Go to For example you're using XAMPP and you cloned this project to , you need to go to

You should see something like:

Play around with the controllers on

How To Use

Controllers

Controllers are located under Every controller MUST extend the SR_Controller.

This REST server supports the most common 4 HTTP Methods: .

When creating a function, this should be the format: . For example, get_name(). If the user accessed /name using the GET method, this method will be invoked. Else, if the user accessed it via POST method, the post_name will be invoked.

To send a response, use the function:

takes in two parameters, the data you want to be the response body (in array) and a status code.

Status codes are defined in

To access the POST or PUT json sent to the server, use the function:

This function will return the json sent to the server in an array format.

To load the model, use the function:

is the class name of your model. You should load the model in your controller's constructor. To use the loaded model, you just need to append the to . For example, I loaded the model in the constructor , to access it inside the functions in my controller, I can call assuming there is a getUser() function inside my model.

Models

Models are located under Every model MUST extend the SR_Model.

To make a query to the database, use the function:

If the SQL statement is a statement, this function will return an array of the result (which you can directly send as a response in the controller). Else, this will return a bool.

To a row, use the function:

If a record was successfully updated, it will return a success json.

Routes

Routes are the heart and soul of this project. It will determine which class and function will be called.

The structure of the route should always be

Customizing Routes

You can customize the routes in the folder.

Here, we are routing to execute the get_index() of the Test class.

We can also add parameters by putting in the place wherein we expect a parameter. This route will invoke the get_name($a) function of Test class, passing any value in place of the to the function.

This project also supports multiple parameters. In this example we passed a name and age in that format. By this route, we tell our REST server to invoke the get_nameage($name, $age) method in the Test class. Also, passing the all the parameters.

Libraries

Libraries are located under

You should load the needed libraries in the constructor of the controller via the command:

JSON Web Token Library

The JWT Library can be used to generate a token.

To generate a token:

is the unique identifier of the user. is the custom payload you want to add to the token

To check if the user passed a VALID json web token to the authorization header:

If it's a valid token, it will return the decoded token and the authorization status ("authorized" or "unauthorized"). Sample response:

Deployment

Since some shared hosting does not read directly from the .htaccess, you may want to enter it manually or ask some help from your hosting provider.

Contributing

When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments


All versions of simplyrest with dependencies

PHP Build Version
Package Version
Requires vinceurag/simplyrest Version v1.0.1
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 vinceurag/simplyrest contains the following files

Loading the files please wait ....