Download the PHP package thewunder/croute without Composer

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

Croute

Latest Version on Packagist

Convention based routing for PHP based on Symfony components.

Croute is great because:

Install via Composer

Via the command line:

composer.phar require thewunder/croute ^2.0

Or add the following to the require section your composer.json:

"thewunder/croute": "^2.0"

Basics

Your index.php should look something like this:

Your controllers should look something like this:

The name of the controller determines which url it appears as:

It supports nested namespaces so that:

Attributes

Croute optionally supports controller and action attributes. Two attributes are included out of the box, HttpMethod and Secure.

HttpMethod

Restricts the allowed http methods. Returns a 400 response if the method does not match.

Secure

Requires a secure connection. If the connection is not https send a 301 redirect to the same url with the https protocol.

Custom Attributes

To create a custom attribute, implement the RoutingAttribute interface on your attribute, and an AttributeHandler.

Add the attribute handler to the router, and your custom attribute will be ready to use.

Events

Symfony events are dispatched for every step in the routing process. A total of 12 events are dispatched in a successful request:

  1. router.request
  2. router.controller_loaded
  3. router.controller_loaded.{ControllerName}
  4. router.before_action
  5. router.before_action.{ControllerName}
  6. router.before_action.{ControllerName}.{actionName}
  7. router.after_action
  8. router.after_action.{ControllerName}
  9. router.after_action.{ControllerName}.{actionName}
  10. router.before_response_sent
  11. router.response_sent
  12. router.response_sent.{ControllerName}
  13. router.response_sent.{ControllerName}.{actionName}

The {ControllerName} will be sans 'Controller' and {actionName} sans 'Action' i.e IndexController::indexAction -> router.before_action.Index.index.

At any time before the response is sent, in an event listener you can set a response on the event to bypass the action and send instead.

Error Handling

Proper error handling is not really something that I can do for you. It's up to you to determine how to do logging, how and when to render a pretty error page. To handle errors, implement the EventHandlerInterface and set your error handler on the router. Your class will be called when common routing events occur (i.e. 404 errors) and when there is an exception during the routing process.

Contributing

Please see CONTRIBUTING for details.


All versions of croute with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
symfony/http-foundation Version ^6.0|^7.0
symfony/routing Version ^6.0|^7.0
psr/event-dispatcher Version ^1.0
psr/container Version ^2.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 thewunder/croute contains the following files

Loading the files please wait ....