Download the PHP package itstructure/laravel-multilingual-tools without Composer

On this page you can find all versions of the php package itstructure/laravel-multilingual-tools. 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 laravel-multilingual-tools

MULT

Laravel multilingual tools

Latest Stable Version Latest Unstable Version License Total Downloads Build Status Scrutinizer Code Quality

MULT package label

1 Introduction

MULT - Package for the Laravel framework to content manage with different languages.

For example, you can store pages in English, Russian, French, German and some another languages...

It is you who add new languages to your application.

All multilingual fields will be with a language postfix, as in example:

title_en, description_en, content_en

title_ru, description_ru, content_ru, e t. c.

2 Dependencies

3 Installation

Note!

Version 2.x is for laravel 8, 9, 10, 11.

Version 1.x is for laravel 7. You can use branch laravel7-mult with 1.x versions.

3.1 General installation from remote repository

Run the composer command:

composer require itstructure/laravel-multilingual-tools "~2.0.5"

3.2 If you are testing this package from local server directory

In application composer.json file set the repository, as in example:

Here,

../laravel-multilingual-tools - directory name, which has the same directory level as your project application and contains MULT package.

Then run command:

composer require itstructure/laravel-multilingual-tools:dev-master --prefer-source

3.3 Next internal installation steps

  1. Publish files.

    • To publish migrations run command:

      php artisan mult:publish --only=migrations

      It stores migration file to database/migrations folder. There is a migration to create languages table.

    • To publish seeder run command:

      php artisan mult:publish --only=seeders

      It stores seeder files to database/seeders folder. There is a seeder to create a first English language DB entry as a default.

    • To publish all parts run command without only argument:

      php artisan mult:publish

    Else you can use --force argument to rewrite already published files.

  2. Run command to run migration and seed:

    php artisan mult:database

    The next will be acted:

    • A table languages will be created.

    • A first English language will be stored as a default.

    Or optional:

    To run just migration php artisan mult:database --only=migrate

    To run just seed php artisan mult:database --only=seed

    • Alternative variant for seeders.

      You can set published MultSeeder seeder class in to a special DatabaseSeeder:

      and run command: php artisan db:seed.

4 Usage

Notes:

4.1 Migration part

First, before a develop multilingual application, make migrations with extending from MultilingualMigration base class.

Example for pages table:

Here,

createMultilingualTable() method provides:

  1. First argument: table name.

  2. Second argument: a callable with multilingual fields.

  3. Third argument: a callable with simple fields.

After applying a migration, two tables will be created automatically:

Note: Timestamps created automatically for both tables.

And the next special columns for pages_languages table with foreign keys will be created automatically:

Example with already stored data:

Main table "pages"

| id | active |    alias    |      created_at     |      updated_at     |
|----|--------|-------------|---------------------|---------------------|
| 1  |    1   | first-page  | 2020-01-14 18:06:33 | 2020-01-14 18:06:33 |
| 2  |    1   | second-page | 2020-01-14 18:10:00 | 2020-01-14 18:10:00 |
| 3  |    0   | third-page  | 2020-01-14 19:05:15 | 2020-01-14 19:05:15 |

Translate table "pages_languages"

| pages_id | languages_id |    title   |      description     |      created_at     |      updated_at     |
|----------|--------------|------------|----------------------|---------------------|---------------------|
|    1     |      1       | Page 1     |     Description 1    | 2020-01-14 18:06:33 | 2020-01-14 18:06:33 |
|    1     |      2       | Страница 1 |     Описание 1       | 2020-01-14 18:06:33 | 2020-01-14 18:06:33 |
|    2     |      1       | Page 2     |     Description 2    | 2020-01-14 18:10:00 | 2020-01-14 18:10:00 |
|    3     |      1       | Page 3     |     Description 3    | 2020-01-14 19:05:15 | 2020-01-14 19:05:15 |
|    3     |      2       | Страница 3 |     Описание 3       | 2020-01-14 19:05:15 | 2020-01-14 19:05:15 |

Language table "languages"

| id | locale | short_name |  name   | default |      created_at     |      updated_at     |
|----|--------|------------|---------|---------|---------------------|---------------------|
| 1  | en-US  |     en     | English |    1    | 2020-01-14 18:06:33 | 2020-01-14 18:06:33 |
| 2  | ru-RU  |     ru     | Русский |    0    | 2020-01-14 18:10:00 | 2020-01-14 18:10:00 |

4.2 Model part

Notes:

4.2.1 Main simple model

Create a main model for base table and use MultilingualModelTrait.

Example model for pages table:

4.2.2 Translate model

Create a model for translates table.

Example model for pages_languages table:

It is not necessary to create relation methods here, such as: page(), language(). It is additional.

4.3 Validation requests part

This request classes can be useful in controller's methods.

Here roles() method makes the next result:

4.4 Controller part

Short page controller example just to create entry:

4.5 View template part

Short example for page.create blade view template:

License

Copyright © 2020-2024 Andrey Girnik [email protected].

Licensed under the MIT license. See LICENSE.txt for details.


All versions of laravel-multilingual-tools with dependencies

PHP Build Version
Package Version
Requires laravel/framework Version ^8.0|^9.0|^10.0|^11.0
php Version >=7.3.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 itstructure/laravel-multilingual-tools contains the following files

Loading the files please wait ....