-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3d3ad7b
Showing
14 changed files
with
482 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/vendor/ | ||
/composer.lock | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
checks: | ||
php: | ||
use_self_instead_of_fqcn: true | ||
uppercase_constants: true | ||
return_doc_comments: true | ||
simplify_boolean_return: true | ||
return_doc_comment_if_not_inferrable: true | ||
properties_in_camelcaps: true | ||
parameters_in_camelcaps: true | ||
overriding_parameter: true | ||
check_method_contracts: | ||
verify_interface_like_constraints: true | ||
verify_documented_constraints: true | ||
verify_parent_constraints: true | ||
avoid_todo_comments: true | ||
encourage_single_quotes: true | ||
line_length: | ||
max_length: '120' | ||
function_in_camel_caps: true | ||
|
||
filter: { } | ||
coding_style: | ||
php: { } | ||
build: | ||
environment: | ||
php: | ||
version: 5.6.9 | ||
version: 7.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
language: php | ||
|
||
|
||
php: | ||
- 5.6 | ||
- 7.0 | ||
- hhvm | ||
|
||
before_script: | ||
- composer install --prefer-source --no-interaction | ||
|
||
script: vendor/bin/phpunit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?php | ||
|
||
namespace Iulyanp\ElixirMixBundle\Command; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Component\Filesystem\Exception\IOExceptionInterface; | ||
use Symfony\Component\Filesystem\Filesystem; | ||
|
||
/** | ||
* Class ElixirMixCommand | ||
* @package Iulyanp\ElixirMixCommand\Command | ||
*/ | ||
class ElixirMixCommand extends ContainerAwareCommand | ||
{ | ||
/** | ||
* Configure. | ||
*/ | ||
public function configure() | ||
{ | ||
$this->setName('mix:init') | ||
->setDescription('Init the bootstrap package.json and webpack.mix.js files.'); | ||
} | ||
|
||
/** | ||
* @param InputInterface $input | ||
* @param OutputInterface $output | ||
* | ||
* @return void | ||
*/ | ||
public function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
$this->writeInfo($output, 'Installing laravel mix...'); | ||
|
||
$container = $this->getContainer(); | ||
$appDir = $container->getParameter('kernel.root_dir'); | ||
$rootDir = $this->getRootDir($appDir); | ||
|
||
try { | ||
$fs = new Filesystem(); | ||
|
||
$packageContent = realpath(dirname(__FILE__)).'/../package.json'; | ||
$packagePath = sprintf('%s%s', $rootDir, 'package.json'); | ||
$fs->copy($packageContent, $packagePath); | ||
|
||
$webpackMixContent = realpath(dirname(__FILE__)).'/../webpack.mix.js.dist'; | ||
$webpackMixPath = sprintf('%s%s', $rootDir, 'webpack.mix.js'); | ||
$fs->copy($webpackMixContent, $webpackMixPath); | ||
} catch (IOExceptionInterface $e) { | ||
$this->writeError($output, $e->getMessage()); | ||
} | ||
} | ||
|
||
/** | ||
* @param OutputInterface $output | ||
* @param string $error | ||
* | ||
* @return mixed | ||
*/ | ||
private function writeError(OutputInterface $output, $error) | ||
{ | ||
return $output->writeln('<error>'.$error.'</error>'); | ||
} | ||
|
||
/** | ||
* @param OutputInterface $output | ||
* @param string $message | ||
* | ||
* @return mixed | ||
*/ | ||
private function writeInfo(OutputInterface $output, $message) | ||
{ | ||
return $output->writeln(sprintf('<info>%s</info>', $message)); | ||
} | ||
|
||
/** | ||
* @param $appDir | ||
* | ||
* @return string | ||
*/ | ||
private function getRootDir($appDir) | ||
{ | ||
return sprintf('%s%s%s%s', $appDir, DIRECTORY_SEPARATOR, '..', DIRECTORY_SEPARATOR); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace Iulyanp\ElixirMixBundle\DependencyInjection; | ||
|
||
use Symfony\Component\Config\Definition\Builder\TreeBuilder; | ||
use Symfony\Component\Config\Definition\ConfigurationInterface; | ||
|
||
/** | ||
* This is the class that validates and merges configuration from your app/config files. | ||
* | ||
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/configuration.html} | ||
*/ | ||
class Configuration implements ConfigurationInterface | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getConfigTreeBuilder() | ||
{ | ||
$treeBuilder = new TreeBuilder(); | ||
$rootNode = $treeBuilder->root('iulyanp_elixir_mix'); | ||
|
||
$rootNode | ||
->children() | ||
->scalarNode('web_dir') | ||
->isRequired() | ||
->end() | ||
->end(); | ||
|
||
|
||
return $treeBuilder; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace Iulyanp\ElixirMixBundle\DependencyInjection; | ||
|
||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\Config\FileLocator; | ||
use Symfony\Component\HttpKernel\DependencyInjection\Extension; | ||
use Symfony\Component\DependencyInjection\Loader; | ||
|
||
/** | ||
* This is the class that loads and manages your bundle configuration. | ||
* | ||
* @link http://symfony.com/doc/current/cookbook/bundles/extension.html | ||
*/ | ||
class IulyanpElixirMixExtension extends Extension | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function load(array $configs, ContainerBuilder $container) | ||
{ | ||
$configuration = new Configuration(); | ||
$config = $this->processConfiguration($configuration, $configs); | ||
|
||
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); | ||
$loader->load('services.yml'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace Iulyanp\ElixirMixBundle; | ||
|
||
use Symfony\Component\HttpKernel\Bundle\Bundle; | ||
|
||
class IulyanpElixirMixBundle extends Bundle | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) <Taylor Otwell> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
ElixirMixBundle | ||
=================== | ||
|
||
ElixirMixBundle is a Symfony bundle that integrates [Laravel Mix](https://github.com/JeffreyWay/laravel-mix). | ||
The purpose of the bundle is to offer the `mix()` twig function. This is exactly the same `mix()` function from Laravel | ||
blade template system. | ||
|
||
### Requirements | ||
|
||
Before you start installing this bundle you first have to ensure that Node.js and NPM are installed on your machine. | ||
|
||
## Installation | ||
|
||
### Step 1: Require the bundle with composer | ||
|
||
Open your terminal and run one of the following commands to download the bundle into your vendor directory. | ||
|
||
If you have composer installed globally you can run: | ||
``` | ||
$ composer require iulyanp/elixir-mix-bundle | ||
``` | ||
Else you can go with: | ||
``` | ||
$ php composer.phar require iulyanp/elixir-mix-bundle | ||
``` | ||
|
||
### Step 2: Register the bundle in your AppKernel class | ||
|
||
Register the bundle in the app/AppKernel.php file of your project: | ||
|
||
``` | ||
<?php | ||
/** app/AppKernel.php */ | ||
class AppKernel extends Kernel | ||
{ | ||
public function registerBundles() | ||
{ | ||
$bundles = array( | ||
new Iulyanp\ElixirMixBundle\IulyanpElixirMixBundle(), | ||
); | ||
} | ||
} | ||
``` | ||
|
||
### Step 3: Initialize larave-mix package | ||
If you already have installed `Node.js`, `npm` you should be all set to run: | ||
|
||
``` | ||
$ php bin/console mix:init | ||
``` | ||
|
||
A base `package.json` and `webpack.mix.js` file will be generated into your project root directory. | ||
|
||
Then run `npm install` to install all the dependencies and [laravel-mix](https://github.com/JeffreyWay/laravel-mix). | ||
|
||
### Usage | ||
Now you can use mix() function to version a file like this: | ||
``` | ||
<link rel="stylesheet" type="text/css" href="{{ mix('css/app.css') }}" /> | ||
``` | ||
|
||
### License | ||
The ElixirMixBundle is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
services: | ||
iulyanp_elixir_mix_extension: | ||
class: Iulyanp\ElixirMixBundle\Twig\MixExtension | ||
public: false | ||
arguments: | ||
- '%web_dir%' | ||
tags: | ||
- { name: twig.extension } |
Oops, something went wrong.