2

I've installed twitter bootstrap via composer and don't have any idea how to reference it in a twig view. I suppose there's a namespace for it but I don't get it.

In this similar question : How to setup bootstrap after downloading via composer? they use artisan to solve this but how to do this in slim php ?

My folder structure:

├── app
│   ├── controllers
│   ├── models
│   └── templates
├── composer.json
├── composer.lock
├── config
│   └── local.php
├── logs
│   ├── README.md
│   └── app.log
├── public
│   ├── css
│   └── index.php
├── src
│   ├── dependencies.php
│   ├── middleware.php
│   ├── routes.php
│   └── settings.php
└── vendor
    ├── autoload.php
    ├── bin
    ├── composer
    ├── container-interop
    ├── doctrine
    ├── illuminate
    ├── monolog
    ├── nesbot
    ├── nikic
    ├── paragonie
    ├── pimple
    ├── psr
    ├── slim
    ├── symfony
    ├── twbs
    └── twig

Composer.json file:

{
        "name": "slim/slim-skeleton",
        "description": "A Slim Framework skeleton application for rapid development",
        "keywords": [
                "microframework",
                "rest",
                "router",
                "psr7"
        ],
        "homepage": "http://github.com/slimphp/Slim-Skeleton",
        "license": "MIT",
        "authors": [
                {
                        "name": "Josh Lockhart",
                        "email": "info@joshlockhart.com",
                        "homepage": "http://www.joshlockhart.com/"
                }
        ],
        "require": {
                "php": ">=5.5.0",
                "slim/slim": "^3.1",
                "monolog/monolog": "^1.17",
                "illuminate/database": "~5.1",
                "slim/twig-view": "^2.1",
                "twbs/bootstrap": "^3.3"
        },
        "autoload": {
                "psr-4": {
                        "App\\Models\\": "app/models",
                        "App\\Controllers\\": "app/controllers"
                }
        }
}
Community
  • 1
  • 1
Biguá
  • 183
  • 3
  • 13
  • The bootstrap files would be in vendor/twbs, what are you asking? All the other question's answer is doing is using artisan's ability to copy the files from the vendor folder to the public folder, so just manually do the same... – Devon Bessemer Sep 12 '16 at 04:42
  • but the path for it seems a little odd to use: salas/vendor/twbs/bootstrap/dist/css/bootstrap.css , is that the right way to use it? If I copy the files from vendor to public, every time it was updated I need to copy again, so.. why use composer ? Dont seems to me the right form. thats why I asked if theres a namespace os something like that. – Biguá Sep 12 '16 at 05:44

1 Answers1

1

You could setup a composer hook to automatically copy the file to your public directory:

{
  "scripts": {
    "post-update-cmd": "cp vendor/twbs/bootstrap/dist/css/bootstrap.css public/",
    "post-install-cmd": "cp vendor/twbs/bootstrap/dist/css/bootstrap.css public/"
  }
}

This should go into composer.json.
Note: Not tested but should work.

danopz
  • 3,310
  • 5
  • 31
  • 42
  • this goes in the composer.json right? when I get home, I will test this. tnx – Biguá Sep 13 '16 at 19:53
  • I've tested and work =) this gonna get a little big, coping every file from bootstrap,glyphicons and bootstrap's js, but its a viable solution. Tnx a lot. – Biguá Sep 14 '16 at 20:13