LastCallMedia / Mannequin

Mannequin Component Theming Tool
https://mannequin.io/
MIT License
38 stars 8 forks source link

Document command usage, including how to set start command address/ports #97

Closed aimevp closed 7 years ago

aimevp commented 7 years ago

I'm having an issue trying to get Mannequin to work.

I've followed the steps in the Drupal example but when I use the command vendor/bin/mannequin start I get the following output:

Starting Mannequin development server...

Tips:

  • Visit http://0.0.0.0:8000 in your web browser.
  • Log messages will be printed below. Use the -v flag for more log data.

[Tue Oct 31 10:38:06 2017] Failed to listen on 0.0.0.0:8000 (reason: Address already in use)

I'm guessing this isn't working because my local lamp stack (Lando) is already using that port 8000. Is there a way to setup Mannequin on a different port of even on a different URL (now it suggests 0.0.0.0:8000)? My local install now for example is on: http://sb-mannequin-test.lndo.site:8000/ It would be nice to access Mannequin on: http://sb-mannequin-test.lndo.site:8001 Or is this not how mannequin works?

Thank you in advance. Aimé.

jlandfried commented 7 years ago

Hi @aimevp, mannequin start has an address parameter that can be used for this. Typically when I run it I do so on port 8082, so I run vendor/bin/mannequin start *:8082 from within a docker container.

If you're running it from within a container you'll have to expose the port that mannequin's listening on as well. I haven't worked with Lando, but here's an example of how we do it in a Drupal scaffolding project we maintain that uses docker-compose https://github.com/LastCallMedia/Drupal-Scaffold/blob/master/docker-compose.yml#L40

Hope this is helpful! Keep us updated if this doesn't get you started, or anything else comes up

aimevp commented 7 years ago

That did it! Now it works.

Could I've found this in the wiki somewhere because afak I didn't see that mentioned anywhere.

rbayliss commented 7 years ago

I don't think we currently have the commands documented, which seems like an oversight. I'll rename this ticket to reflect that we should do that.

rbayliss commented 7 years ago

Command line documentation has been added here!

dave-cross commented 7 years ago

Sorry if this re-opens the issue, but I'm curious what Aimé's solution was.

@aimevp Could you share how you got Mannequin into Lando? Could you share that section of your .lando.yml file? I'm trying to do the same thing and would appreciate a little help. 🙂

aimevp commented 7 years ago

Hi @cloudsociety, actually I didn't have to add anything in my .lando.yml file.

What I did was install Drupal 8 using the Composer template for Drupal projects which created a project root with a "web" directory that holds the web/drupal root. After that I initialized my Lando with lando init --recipe drupal8, started it and installed drupal. Lando provides a few URL's to work on but I wanted to use the one without https and the 'lando name' which uses port 8000 (the same as Mannequin would). Example: http://sb-mannequin-test.lndo.site:8000

Then I added Mannequin to my project using composer (as suggested on the mannequin docs). Using Lando I altered the command to lando composer require lastcall/mannequin-drupal.

In my project root I added the .mannequin.php file using following config:

<?php

use LastCall\Mannequin\Core\MannequinConfig;
use LastCall\Mannequin\Drupal\DrupalExtension;
use Symfony\Component\Finder\Finder;

$drupalFinder = Finder::create()
  ->in([__DIR__ . '/web/themes/custom/<name_of_your_theme>'])
  ->files()
  ->name('*.twig');

$drupalExtension = new DrupalExtension([
  'finder' => $drupalFinder,
  'drupal_root' => __DIR__ . '/web',
  'twig_options' => [
    'auto_reload' => TRUE,
  ],
]);

$config = MannequinConfig::create()
  ->addExtension($drupalExtension)
  ->setGlobalCss(
    [
      'web/themes/custom/<name_of_your_theme>/path/to/your.css',
    ]
  )
  ->setGlobalJs(
    [
      'web/core/assets/vendor/jquery/jquery.min.js',
      'web/core/assets/vendor/domready/ready.min.js',
      'web/core/misc/drupal.js',
      'web/core/misc/drupal.init.js',
      'web/themes/custom/<name_of_your_theme>/path/to/your.js',
    ]
  );

return $config;

Once all of this is in place I started Mannequin using the command suggested in this thread with the added port parameter outside of Lando: vendor/bin/mannequin start *:8082

Finally I opened a new tab in my browser using following URL: http://sb-mannequin-test.lndo.site:8082 where I get to see Mannequin running.

I'm new to Lando as well so there might be a better solution to automate the bootup of Mannequin inside Lando (using the .lando.yml file) but I don't know yet how to do this.

Hope it helps anyway.

dave-cross commented 7 years ago

@aimevp,

Awesome! hopefully, we can find a way to start Mannequin from within the container. Then, we can use events to start it or have it started automatically as a service.

Until then, this works. Thank you for sharing.