Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Redaktilo Laravel Package

gnugat/redaktilo

Redaktilo adds a simple, developer-friendly API to manage and manipulate text content in PHP, with utilities for formatting and transforming strings in a consistent way. Useful when you need reusable text handling logic without pulling in a heavy framework.

View on GitHub
Deep Wiki
Context7

Redaktilo

Redaktilo allows you to find, insert, replace and remove lines using an editor-like object.

Because your code too needs an editor to manipulate files.

Getting started

Use Composer to install Redaktilo in your projects:

$ composer require "gnugat/redaktilo:^2.0"

Redaktilo provides an Editor class which can be instanciated using EditorFactory:

<?php
require_once __DIR__.'/vendor/autoload.php';

use Gnugat\Redaktilo\EditorFactory;

$editor = EditorFactory::createEditor();

Real life example

For our example, we will create a KernelManipulator similar to the one we can find in SensioGeneratorBundle.

It takes a bundle's fully qualified classname and inserts it in the AppKernel file:

<?php

namespace Sensio\Bundle\GeneratorBundle\Manipulator;

use Gnugat\Redaktilo\Editor;

class KernelManipulator extends Manipulator
{
    protected $editor;
    protected $appKernelFilename;

    public function __construct(Editor $editor, $appKernelFilename)
    {
        $this->editor = $editor;
        $this->appKernelFilename = $appKernelFilename;
    }

    public function addBundle($bundle)
    {
        $appKernel = $this->editor->open($this->appKernelFilename);
        $newBundle = "            new $bundle(),";
        if ($this->editor->hasBelow($appKernel, $newBundle)) {
            $message = sprintf('Bundle "%s" is already defined in "AppKernel::registerBundles()".', $bundle);

            throw new \RuntimeException($message);
        }
        $this->editor->jumpBelow($appKernel, '        );');
        $this->editor->insertAbove($appKernel, $newBundle);
        $this->editor->save($appKernel);

        return true;
    }
}

As you can see it's easier to read and to understand than the original PHP token parsing.

Further documentation

You can see the current and past versions using one of the following:

You can find more documentation at the following links:

Next readings:

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
cadot.eu/make
besmartand-pro/php-quality-config
sentix/ai-chatbot
codifyo/ts-generator-bundle
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky