Download the PHP package upon/mlang without Composer

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

High-Performance Multi-Language Package for Laravel

Build Status License

This package is a high-performance solution designed to provide efficient multi-language support for Laravel applications. It offers robust features and optimizations to ensure fast and reliable language management, making your application accessible to a global audience without sacrificing performance.

Version Compatibility

This package follows Laravel's major versioning for compatibility.

Package Version Supported Laravel Versions PHP Requirements Architecture
^1.0 Laravel 10.x PHP >= 8.1 Model inheritance approach
^2.0 Laravel 11.x, 12.x PHP >= 8.3 Trait and interface approach

Note: If you are using Laravel 11 or 12, please use version ^2.0 of this package.
For Laravel 10, continue using version ^1.0.

The architecture has changed between versions - v1 uses model inheritance while v2 uses traits and interfaces.

Features

Database Structure

This package adds two essential columns to the models you specify:

Requirements

This package requires the following dependency:

Installation

  1. Install the package using Composer:

  2. Publish the package configuration and language files:

  3. Configure the package by modifying the config/mlang.php file according to your requirements. You can specify:

    • Supported locales
    • Default locale
    • Translatable models
    • Auto-generation settings
    • Auto-migration hooks
    • Observer behavior
  4. Configure your models in the mlang config file:

  5. Use MLang in your models:

For Version 1.x: Extend your models with MlangModel instead of the default Eloquent Model:

For Version 2.x: Use the trait and implement the interface instead of extending the model:

  1. Run the migration command to add the required columns to your models:

Using the Facade

MLang comes with a powerful facade that provides a fluent interface for interacting with the package. After installation, you can use the facade as follows:

Configuration Options

The package offers various configuration options to fine-tune its behavior:

Working with Factories

The package is designed to work safely with factories even before migrations have run. It intelligently detects when MLang columns don't exist and avoids trying to use them in such cases.

To ensure smooth operation with factories:

  1. Set 'auto_generate' => false in your config file when using factories before migrations.
  2. The trait will automatically detect missing columns and adjust behavior accordingly.
  3. After running migrations, you can enable auto-generation features.

Version 2.x additional benefits: The trait-based approach in version 2 makes it even easier to work with factories before migrations, as it has enhanced column existence detection and more graceful fallbacks.

Managing Translations

Using Artisan Commands

Generate translations for all models:

Generate translations for a specific model:

Generate for a specific language:

Remove a language from a table:

Using the Facade

You can also manage translations programmatically using the facade:

Language Detection

To automatically detect the user's browser language:

  1. Add the locale middleware to your app/Http/Kernel.php file:

To manually set the language:

Query Usage

Both package versions provide the same query methods for working with multilingual content:

Finding Records

To find a record by ID, translated to the current application language:

Querying with Conditions

To query with conditions while respecting language context:

The trWhere method works like the normal where but automatically maps id to row_id and adds a language condition, allowing you to chain other query methods:

Route Model Binding

The package enhances Laravel's route model binding to automatically fetch the correct language version:

Understanding Interface and Trait Relationship

When implementing MLang v2.x in your models, it's important to understand the relationship between the interface and trait:

  1. The Interface (MlangContractInterface) defines the contract that your models must fulfill to be MLang-compatible.

  2. The Trait (MlangTrait) provides the actual implementation of the methods required by the interface.

You must use both together:

This provides several benefits:

Contributing

Contributions are welcome! If you encounter any issues, have suggestions, or want to contribute to the package, please create an issue or submit a pull request on the package's GitHub repository.

License

This package is open-source software licensed under the MIT license. Feel free to use, modify, and distribute it as per the terms of the license.

Credits

This package was developed by Reymon Zakhary. Special thanks to the Laravel community for their support and inspiration.

Contact

If you have any questions or need further assistance, you can reach out to the package maintainer at [email protected].


All versions of mlang with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
ext-filter Version *
illuminate/database Version ^v11.44.7|12.*
illuminate/support Version ^v11.44.7|12.*
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 upon/mlang contains the following files

Loading the files please wait ....