1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XenForo CLI - making our lives easier

Discussion in 'XenForo Development Discussions' started by Naatan, Jun 4, 2012.

  1. Naatan

    Naatan Well-Known Member

    For the past month or so, Robbo and I have been working on an ambitious project to create a command line tool for XenForo. The reason being that we both felt having to always switch between IDE and editor was costing a lot of time and worse, it was ripping us out of the "zone".

    Currently the CLI already implements a lot of commands, some examples of what it can do:
    • Create a new addon and generate basic file structure
    • Install / Update / Uninstall addons
    • Import an addon from git or mercurial (experimental)
    • Show information about addons
    • Extend existing XenForo classes
    • Create event listeners
    • Create routes and their related controllers
    • Manage phrases & templates
    • Rebuild your caches
    • More .. (see the readme for details)
    All of these commands are working for the most part, but should be considered as alpha. We have not yet entered the polishing phase and are currently simply adding features and extending upon existing ones.

    That said, I'd like to invite anyone interested over to the Github repository and our discussion group to contribute (be it by providing feedback or actual code) and make this project a success, you can find the links below.

    Hope to get some good feedback and useful contributions!
    lol768, ibnesayeed, TrevC and 20 others like this.
  2. Naatan

    Naatan Well-Known Member

    I'm a bit surprised by the lack of response to this. Surely Robbo and I can't be the only ones that see the value in this?

    Please, if you find the project interesting but not useful in it's current state for any other reason besides it being alpha, let us know. Part of the purpose for my posting this thread is to get useful feedback.
  3. Chris D

    Chris D XenForo Developer Staff Member


    I am interested. Though I expressed it in rather a lazy way by merely liking your post.

    For me to be more interested, I'd probably need specific details on how to use it.

    I'd also be happy to test out some of its functions on my test board if, for example, you can provide basic instructions on how to install an add-on with it.
  4. ragtek

    ragtek Guest

    Hm, i'm intersted too, but i'm having & using my own tools for a long time and too many things are "hardcoded"
    sc2.PNG sc.PNG
    and include ugly code like:
    $name 'Ragtek_' substr($addOnId6) . '_Hashes';
    $hashFileContent XenForo_Helper_Hash::getHashClassCode($name$this->hashes);
    $directory 'upload/library/Ragtek/' substr($addOnId6) . '/Hashes.php';
        protected function 
    $structure '';
            if (
    $structure .= "Ragtek_" substr($this->_addon['addon_id'], 6) . '_';
            else {
    // TODO i need to change this
    die('only ragtek add-ons are supported ATM');
    As i started developing add-ons, i've decided to put all my add-ons into the "ragtek" directory, so it's easier to use my add-ons via symlink for > 30 boards (http://xenforo.com/community/threads/move-config-php-out-of-library-directory.8970/ )
    so i'm not able to use https://github.com/Naatan/XenForo-CLI or https://github.com/daohoangson/DevHelper

    now it would be a too big "refactoring challenge" to move everything out of the ragtek directory
  5. Naatan

    Naatan Well-Known Member

    Thanks Yorick, I will certainly add more documentation, unfortunately I'm not very good at writing documentation as my head is too much in the code, it makes it hard to look at it from a newcomers perspective. Either way I'll do my best and write up some info to get people started.

    Actually this is already possible, the "addon add" command allows you to specify the directory the addon is in, so you can have your own namespace directory.

    I see you basically had the same "problem" as us, being that some things are just too tedious to do repeatedly. I think having a web interface for it is an interesting solution but it still draws you out of your IDE. Why not join us in developing the CLI and add some of the tools that you are currently missing in it?

    A nice side-effect of doing this with a larger group of developers is that you have constant code-review, essentially forcing you to a certain level of code quality. And if you miss something, other developers might catch it.
  6. Chris D

    Chris D XenForo Developer Staff Member

    Maybe if I get my head around it all I could start writing documentation for you.

    But - clear something up for me - I assume I need to install this as an add-on first? Or maybe not?

    Then how would I actually run the commands?
  7. Naatan

    Naatan Well-Known Member

    These installation steps are preliminary and will be polished when we head into beta, but at the moment you simply download the project and put the "xf" file on your PATH (Mac & Linux). Currently Windows is not supported but we'll be adding support very soon.

    Once you can run "xf" from any directory you go either in your xenforo, library or addon directory and execute "xf", it will then give you information on what commands you can run.

    I'll provide a more detailed step-by-step guide soon.
  8. Chris D

    Chris D XenForo Developer Staff Member

    Sounds good, thanks.

    I have access to Linux and Mac, but my primary OS is Windows so that functionality is important for me, but won't stop me from having a play, thank you :)
  9. duderuud

    duderuud Active Member

    Rebuilding cache through CLI sounds good. Especially if you have a very large DB (like we have in testing).
    That way you don't have to keep your browser open (and pc on).
    Naatan likes this.
  10. Robbo

    Robbo Well-Known Member

    Even better. If you have an addon installed from github you can simple run "xf addon update" and it will grab all updates, update the addon and rebuild caches for you :)

    We have wanted rebuild times to also be much faster and Naatan has looked at ways to improve the time but is yet to find anything to speed it up a lot.
  11. Brandon Sheley

    Brandon Sheley Well-Known Member

    I did the same :)
    I would love to use CLI for large forum upgrades or imports.
  12. Robbo

    Robbo Well-Known Member

    Imports are a whole new beast that I doubt we will do. However we have the foundation to do it on.
    XenForo upgrades will most likely be in a release to remove the browser steps from the situation.

    The parts I work on are generally to work with git or hg. I deploy websites with them and by using hooks can have certain functionality run on the command line by the server when I push an update.
    For example a XenForo upgrade gets pushed to my server, the server detects it when it receives the new changes at puts the forum into maintenance and executes the updates without me doing a thing. (this isn't possible yet though)
  13. Naatan

    Naatan Well-Known Member

    What I plan to do is make the CLI modular, so that if someone develops an upgrader or importer they can easily hook this into the CLI (or simply use the CLI as a dependency).
    SchmitzIT and Brandon Sheley like this.
  14. DRE

    DRE Well-Known Member

    I have XFCliImporter on my server and I don't remember installing it or where I got it from. What's it for? I don't see the addon on my site either.
  15. ragtek

    ragtek Guest

  16. DRE

    DRE Well-Known Member

  17. Naatan

    Naatan Well-Known Member

    This has nothing to do with the project that this thread is about. But yes, you can.
  18. DRE

    DRE Well-Known Member

    I searched for CLI Importer and this came up, sorry.
  19. Forsaken

    Forsaken Well-Known Member

    Why not call it "XenForo Developer CLI"?

    As it is, I was confused the first time I saw the title as well.
    ragtek likes this.
  20. Naatan

    Naatan Well-Known Member

    Because while the current feature set is mostly targeted at developers it's meant to evolve to be a general toolkit for XenForo usable by anyone comfortable with the CLI.

    You can easily see from the first post that this is not about the CLI Importer.
    simbolo likes this.

Share This Page