Download the PHP package tonka/spark without Composer

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

Tonka/Spark đŸŒŠī¸

The secure bridge between your Tonka Framework backend and your frontend router.

Spark is the server-side package responsible for exposing, filtering, and formatting your named routes for the tonka-router package. It features dynamic access control through Policies, allowing you to hide sensitive routes from unauthorized users effortlessly.

🌟 Why use Spark?

Exposing all your backend routes to the browser is a security risk. Spark solves this by giving you fine-grained control over what is visible to the frontend, leveraging your existing Policy classes to determine visibility based on the current user's role.

✨ Features

âš™ī¸ Configuration

Publish the configuration file:

This will create config/spark.php:

🧭 Groups vs. Policies: Why Use Both?

You might wonder: "If Policies handle security, are Groups necessary?"

The short answer is yes. They serve distinct but complementary purposes:

Why combine them?

  1. Performance: Without groups, sending all authorized routes (which could be hundreds) to a simple login page is wasteful. Using groups keeps the JSON payload small and fast.
  2. Maintainability: Groups allow you to update route lists in one place (config/spark.php) instead of hardcoding arrays in every Blade file.

🚀 Usage

1. Injection in Views (Recommended)

Use the @routes directive in your main layout.

How it works with Policies: When the page loads, Spark iterates through your configuration. For every route matching your rules, it checks the associated Policy.

2. File Generation

Generate a static routes file for SPAs:

This creates a routes.json file reflecting the current user's permissions.

3. API Endpoint

For dynamic fetching:

🔐 Security Best Practices

  1. Use Policies for Sensitive Routes: Do not rely solely on frontend hiding. Use the policy key to ensure backend logic prevents unauthorized routes from ever reaching the browser.
  2. Avoid except if possible: Whitelisting (only) is generally safer than blacklisting (except) for API exposure.
  3. Validate Policy Methods: Ensure your Policy classes have a public authorize() method that returns a boolean.

📚 Integration with Tonka Router

Once exposed, your frontend consumes the routes seamlessly:


All versions of spark with dependencies

PHP Build Version
Package Version
Requires php Version >=8.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 tonka/spark contains the following files

Loading the files please wait ...