Download the PHP package llwebsol/rapid without Composer

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

Build Status Latest Stable Version Scrutinizer Code Quality Code Intelligence Status

Total Downloads License

rAPId

a simple and minimalist framework for php APIs

Getting Started

To create a project called YourProject:

  1. Create an empty directory for your project and cd into it
  2. set up your project with $ composer init requires composer.

  3. Add to your composer.json

Now run composer update and the necessary files should be automatically added to your projects root directory.

Docker

a default Dockerfile and docker-compose.yml will have been added to your root directory. You may edit these as needed, or spin up the default Docker environment with docker-compose up. Your app will be available on localhost:5000

Controllers

Add a new file to the new Controllers directory that was added (it may be in src/Controllers)

Example default controller

(src/Controllers/Main.php):

Until you add another controller or method, all routes will point to the index method in your Main controller

Next update your rAPIdConfig.php

Adding Routes

Routes can be added to your project by adding new controllers and new controller methods.

Example: if you navigate to http://www.your-project-url.com the Main::index() function will fire.

If you were to add the function doSomething() do your main controller, then navigate to your-project-url/do-something (or your_project_url/do_something if you prefer underscores)

You could also add new routes by adding a new controller

example: (src/Controllers/SomethingElse.php)

Now navigating to http://www.your-project-url.com/something-else will render "You are in the Index"

while navigating to http://www.your-project-url.com/something-else/another-thing/ will render "You are in Another Thing"

Input

You can specify input parameters in your public controller methods.

For example, if you were to add the following function to YourProject\Controllers\SomethingElse:

There are 3 ways to receive input.

1:

You can receive data directly through the url:

http://www-your-project-url.com/something-else/get-data/11/76


2:

You can receive data through query parameters (through a GET request only)

http://www-your-project-url.com/something-else/get-data?another_var=76&a_var=11

Notice the order doesn't matter, but the parameters will be mapped to their names in the function. If your query string contains a key that is not definied in your function, it will be ignored

http://www-your-project-url.com/something-else/get-data?another_var=76&an_undefined_var=11


3:

You can receive data through POST params

example:

a POST request to http://www-your-project-url.com/something-else/get-data

with the parameters ['a_var' => 11, 'another_var' => 76]

will output:

Similar to a GET request with query parameters, undefined parameter keys will be ignored


Notes

Output

Anything that you return from a controller will be serialized and returned to the user with the correct header

If nothing is returned from your controller method, then nothing will be output in this way. If you wish to serve an image, handle outputting that image yourself, and don't return anything from your controller

The type of serialized output that your API returns is determined by the output_serializer variable in your rAPIdConfig.php

Json and XML are currently supported. If you wish to output some other kind of data, you can write your own serializer that implements rAPId\Data\Serialization\Serializer, then feel free to submit a pull request!

Database

rAPId uses the llwebsol/EasyDB package for simple database interactions

a .env.example file should have been placed in your projects root directory. Copy this file to .env, then overwrite with your database credentials, and obviously, don't check this file in to your version control

You can now access an instance of EasyDB by calling the helper function

Database Event Listeners:

You can make use of the EasyDB event system by creating a class that implements the EasyDb\Events\Listener interface, then register that listener in your config/database.php

example:

-if you create a Listener class for updating the modified_user for each database insert/update:

Multiple Database Connections:

if you need to connect to another database, add your new credentials into the .env

example:

Then update your config/database.php

Note that the db() helper function will return a connection to your primary database by default.

to connect to "secondary" in the above example:

Other

Throwing an InvalidUrlException will display your default 404 page. Once you have a default controller set up, all invalid routs will go through the index() in that class. If you don't wish something to be rendered for some random url, then consider throwing this exception in your default controllers index

example:

my-site.com/xyz will return a 404 response, wile my-site.com/test will return a valid response

Initialization

rAPId also unpacks an initialize.php file into your root directory. You can put any initialization code in this file.


All versions of rapid with dependencies

PHP Build Version
Package Version
Requires llwebsol/easy-db Version ^1.0
vlucas/phpdotenv Version ^2.4
php Version ^7.1.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 llwebsol/rapid contains the following files

Loading the files please wait ....