Loïc Faugeron Technical Blog

Redaktilo v0.7 27/05/2014

TL;DR: jump to the conclusion.

Since the announcement of Redaktilo on this blog, this silly library has jumped from 164 lines of code in v0.3 to 571 in v0.7.

In this article:

  1. we'll quickly oversee the changes done
  2. then we'll have some insight on the upcoming changes
  3. finally I'll list the remaining unresolved questions

Changes done

Thanks to WouterJ you can now:

I've updated to documentation to make the library easier to learn with:

Redaktilo has been created to fulfill actual needs. To make sure it keeps this promise, I've added executable examples using PHPUnit tests.

The major changes have been massive refactorings to allow the library to be extended:

As highlited by Clément Herreman, those refactorings have introduced a more complex construction schema. To make things easier, a static Dependency Injection Container has been created.

Upcoming changes

Sublime Text's go to anything feature is really awesome, which is why I'd like to implement something similar:

The two first ones are already available, so the other one still have to be implemented (the last one might be done by Loick Piera).

The methods allowing this throw exception when nothing is found. Adding a relative check (hasBefore and hasAfter) might make things easier.

Moving relatively isn't always sufficient. To go to an absolute line number you have to use directly File, maybe it would be nicer to add a new method to Editor (jumpToFirst).

Finally, the editor should allow insertion, replacement and removal in any locations, not just on the current line.

Once these features added, more refactoring should take place: since the creation of Redaktilo, Jean-François Simon advised me to use the command and memento patterns, which would allow the undo/redo feature. While I now think that Command is indeed more suitable than ReplaceStrategy for insertion, replacement and removal, I'm not sure the versioning feature is actually needed... For now.

And that should bring us near an alpha version :) .

A lot of renaming should happen at this stage:

And perhaps some other methods or class names.

Once the heavy renaming done, beta versions can begin, with a main focus on making every thing safer (argument checking, exception handling).

Remaining unresolved questions

I'm still not fully sure of what Redaktilo v1.0 will look like. Mainly because I still haven't anwsered this by question (which have been in my mind since the begining):

Should Redaktilo handle different kinds of files?

Sometimes I think it should, which is why the project has seen:

The motives behind this is the JSON use case: you can currently edit JSON files, but it's tedious.

Let's take the composer.json example. What if you need to add a script when:

Another example would be the addition of a new element in an array: you currently have to manually a trailing comma to the previous entry...


Redaktilo fulfills 98% of my use cases (inserting new lines in a YAML configuration file, editing PHP files and replacing bits in a documentation file) and is now extensible.

Some search strategies will be added to make it similar to the Sublime Text's go to anything, and some refactoring are still necessary before an alpha version.

There's still some unresolved questions (JSON edition is the 2% use case left), but I'm sure they'll be answered during the development.

In the end Editor should have the following methods (no guaranty on the names):

I'd like to thank the early contributors:

Any help is appreciated, whether it's some code review, typo fixing or code/documentation contribution. But the biggest help you could give me: provide me with some feedback on Redaktilo's usage :) .

If you have any questions, remarks, please feel free to open an issue and start a discussion here.