---
title: "Using the TinyMCE composer package with the Laravel framework"
description: "A guide on integrating the TinyMCE Composer package into the Laravel framework."
canonical_url: "https://www.tiny.cloud/docs/tinymce/latest/laravel-composer-install/"
md_url: "https://www.tiny.cloud/docs/tinymce/latest/laravel-composer-install/index.md"
version: "latest"
last_updated: "2026-09-11T04:39:13Z"
tokens: 1269
---
# Using the TinyMCE composer package with the Laravel framework

[Laravel](https://laravel.com/) is a scaleable web application framework built on PHP. This guide assists with adding TinyMCE from the [TinyMCE Composer package](https://packagist.org/packages/tinymce/tinymce) to pages or views in Laravel. The example Laravel project created in this procedure is based on the Laravel project documented in the Laravel Docs, under [Installation Via Composer](https://laravel.com/docs/8.x/installation#installation-via-composer). The guide will create two blades: one for the JavaScript and another for the editor placeholder, to reflect how TinyMCE should be used in production environments.

## Requirements

This procedure assumes the following prerequisites have been installed:

- [PHP](https://www.php.net/)
- [Composer](https://getcomposer.org/)
- [Node.js](https://nodejs.org/)

## Procedure

1. On a command line (or command prompt), create a new Laravel project named `my-example-app` by running the following command:

```sh
composer create-project laravel/laravel my-example-app
```
2. Change into the root directory of the Laravel application, such as:

```sh
cd my-example-app
```
3. Install the required Node.js components, including [Laravel Mix](https://laravel.com/docs/8.x/mix):

```sh
npm install
```
4. Add TinyMCE to the project using Composer:

```sh
composer require tinymce/tinymce
```
5. Add a Laravel Mix task to copy TinyMCE to the public files when Mix is run, such as:

*File:* `webpack.mix.js`

```js
mix.copyDirectory('vendor/tinymce/tinymce', 'public/js/tinymce');
```
6. Run Laravel Mix to copy TinyMCE to the `public/js/` directory:

```sh
npx mix
```
7. Create a new reusable [component (`blade.php`)](https://laravel.com/docs/8.x/blade#components) for the TinyMCE configuration, such as:

```sh
php artisan make:component Head/tinymceConfig
```
This will create the blade `resources/views/components/head/tinymce-config.blade.php`.
8. Open the newly created `.blade.php` file in a text editor and replace the contents with:

  - The TinyMCE source script.
  - A TinyMCE configuration.

For example:

*File:* `resources/views/components/head/tinymce-config.blade.php`

```html
<script src="{{ asset('js/tinymce/tinymce.min.js') }}" referrerpolicy="origin" crossorigin="anonymous"></script>
<script>
  tinymce.init({
    selector: 'textarea#myeditorinstance', // Replace this CSS selector to match the placeholder element for TinyMCE
    plugins: 'code table lists',
    toolbar: 'undo redo | blocks | bold italic | alignleft aligncenter alignright | indent outdent | bullist numlist | code | table'
  });
</script>
```
9. Create a second blade containing a placeholder HTML element for TinyMCE, such as:

```sh
php artisan make:component Forms/tinymceEditor
```
This will create the blade `resources/views/components/forms/tinymce-editor.blade.php`.
10. Open the newly created `.blade.php` file in a text editor and replace the contents with a placeholder, matching the CSS selector provided to the `selector` option in the editor configuration.

For example:

*File:* `resources/views/components/forms/tinymce-editor.blade.php`

```html
<form method="post">
  <textarea id="myeditorinstance">Hello, World!</textarea>
</form>
```
11. Add the blade components on the pages or views where TinyMCE is needed. The configuration blade (`Head/tinymceConfig` in this example) can be added to the `<head>` or at the end of the `<body>` on the target page or view. The placeholder blade (`Forms/tinymceEditor`) should be added where TinyMCE is required on the page.

For example:

*File:* `resources/views/welcome.blade.php`

```html
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>TinyMCE in Laravel</title>
    <!-- Insert the blade containing the TinyMCE configuration and source script -->
    <x-head.tinymce-config/>
  </head>
  <body>
    <h1>TinyMCE in Laravel</h1>
    <!-- Insert the blade containing the TinyMCE placeholder HTML element -->
    <x-forms.tinymce-editor/>
  </body>
</html>
```
12. Start the Laravel development server to verify that TinyMCE loads on the page or view, such as running the following command and opening the page on the localhost.

```sh
php artisan serve
```

## Next Steps

For information on:

- Setting the license, see: [Setting the license](../license-key/#setting-the-license).
- Customizing TinyMCE, see: [Basic Setup](../basic-setup/).
- The three editor modes, see:

  - [TinyMCE classic editing mode](../use-tinymce-classic/).
  - [TinyMCE inline editing mode](../use-tinymce-inline/).
  - [TinyMCE distraction-free editing mode](../use-tinymce-distraction-free/).
- Adding TinyMCE plugins, see: [Work with plugins to extend TinyMCE](../work-with-plugins/).
- Localizing the TinyMCE editor, see: [Localize TinyMCE](../localize-your-language/).
- For information on the CSS required to render some TinyMCE elements outside of the editor, see: [CSS for rendering TinyMCE content outside the editor](../editor-content-css/).
