Phinx path with subfolders - migration

i want to have a better overview on the phinx migration files. i want something like this
/db/migration/1.8.5/ID-2065/my_file_name_1234567890
So i can use
'migrations' => '%%PHINX_CONFIG_DIR%%/db/migrations/'. $_ENV['APP_VERSION'],
In the docs only is something like this
migrations: %%PHINX_CONFIG_DIR%%/module/*/{data,scripts}/migrations
But how can i use there maybe a param from the command line.
See you

If your using the default YAML based configuration you can try using Phinx ENV vars (PHINX_ prefix) and then use a %%PHINX_VARNAME%% replacement. Note: I haven't actually tried this before. Read more about them here: http://docs.phinx.org/en/latest/configuration.html#external-variables
Otherwise if your using a PHP-based configuration file you can definitely access the $_ENV superglobal as you have described. Just be sure to call your bootstrap/init scripts so your application version is injected.
Rob

Related

Prevent IHP RunDevServer from automatically opening a window or tab

Is there a way to start the server without it automatically opening a tab? Something similar to webpack serve --no-open
You can set the IHP_BROWSER environment variable to echo before running the dev server:
export IHP_BROWSER=echo
./start
This is described in the IHP recipes:
https://ihp.digitallyinduced.com/Guide/recipes.html#dont-autoopen-the-app-in-the-browser
Adding a little more to the accepted answer.
The answer can be found on the Recipes page in the Documentation along with other helpful best-practice solutions. Another solution is to append export IHP_BROWSER=echo to the local .envrc file.
// .envrc
PATH_add /nix/store/...
export IHP_BROWSER=echo

Spread all dotenv keys and values to process.env without having to define it one by one in serverless.yml

I am using node & expressjs as an app. I have problem in deploying it to serverless with dotenv (without using any dotenv plugin).
My serverless.yml is this:
functions:
server:
handler: index.server
events:
- http: ANY /
- http: "ANY /{proxy+}"
environment:
ENV_VAR1: ${env:ENV_VAR1}
and my .env.staging is this:
ENV_VAR1='ENV_VAR1 using .env.staging'
ENV_VAR2='ENV_VAR2 using .env.staging'
I use AWS Lambda and deploy it using sls deploy --stage staging. So far I can read the ENV_VAR1from .env.staging by calling process.env.ENV_VAR1 because I explicitly define it in the serverless.yml file. But that's not the case with ENV_VAR2.
My question is, how to load all the .env.{stage} file without defining the key one by one?
I hope to load it similar to something like this:
environment: ${file(.env.${self:stage})}
Thank you in advance.
As I know, there is no way, you'll have to do it one by one (you have to have an object with key-value pairs inside environment, but you are trying to give it a string - even if it is going to be interpreted as a file containing something, it is still a string when you are referencing it).
I'm not an expert, so there still might be some tricks.

How do you run a Yii command from within your Module?

Is it possible to have my module's custom commands show up in the list of application commands when you run yiic?
cd {yii_protected_folder}
yiic shell {full_path_to_my_yii_protected_folder}/config/console.php
I've tried adding the command into the commandMap array in console.php, but the command never shows up as an option in yiic.
'commandMap'=>array(
'passwordtest'=>array(
'class'=>'application.modules.myModule.commands.shell.passwordtestCommand',
),
The only way I can make it show up in yiic is to copy the passwordtestCommand.php file to {yii_protected_folder}/commands/shell/, but I'd rather keep the file within my module and reference it somehow.
It's actually not that hard, the CConsoleApplication-class has a getter for the CConsoleCommandRunner. This in its turn has an "addCommands()"-function that allows you to add paths. Just open up your protected/yiic.php and change it by this:
<?php
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r'));
defined('YII_DEBUG') or define('YII_DEBUG',true);
require_once(dirname(__FILE__).'/../yii/yii.php');
$app = Yii::createConsoleApplication(dirname(__FILE__).'/config/console.php');
$app->commandRunner->addCommands('extraCommandPath');
$app->commandRunner->addCommands('extraCommandPath2');
$app->run();
After that you no longer require the yiic.php from the framework.
That should do it.
'commandMap'=>array(
'passwordtest'=>array(
'class'=>'application.modules.myModule.commands.shell.passwordtestCommand',
),
this help me with run module command in Yii 1.x
just add it into config/console.php or your different console config file.
also change the path part ".myModule.commands.shell.passwordtestCommand"
cheer, it's working for me.

output_path not working in behat 2.4.0?

I'm experiencing problems with HTML formatter and the output_path in behat. I'm using cmd:
behat --format=html --out=output.html --config /www/config/behat.yml test.feature
Simplified config (behat.yml) looks like this:
default:
formatter:
name: html
parameters:
output_path: /www/features/output
The problem is that no matter what output_path I set, the output.html is always placed inside same directory, where is behat.yml (/www/config). Can anybody see what am I doing wrong?
Thanks a lot for help!
UPDATE Behat v 2.4.3 use the output dir same as current dir (not the same as config), but still output_path parameter in behat.yml seems not working.
consider using the command line args and see if the issue still happens
for example:
/bin/behat --config=/pathToYML -f pretty,progress,junit --out path/to/output/file/for/pretty,,path/to/junit/output/file /path/to/behat/features/folder
The command line stuff seems to want all three if you don't specify something it will output to console which is why there are , , between pretty and path
This could hold a clue as to why you are having a problem if the command line wants more than one option by default you might need to configure your yaml for that as well.
Our shell script just feeds the command line what we want dynamically instead of doing guess work with yaml configs. Good luck
I had the same issue with behat 2.4.0, this was a known bug that was fixed on version 2.4.3.
Installation method #2 (PHAR) in the guide unfortunately only gives you version 2.4.0 at the time of writting... So in order to fix this you'll have to use the composer method #1.
Hope that helps!

Multiple public folders, single rails installation

I have a rails application I would like to use for multiple sites, each with different designs.
I would like to change the rails installation /public directory to something else (dynamically eventually). However, I have run into a problem (bug?) changing directories...
In my application.rb file I change the paths.public path to something other than "public" (let's say "site_one"). Here is the code:
puts paths.public.paths
paths.public = "site_one"
puts paths.public.paths
The two "puts" commands are for debugging. Now run "rails s" and you will see:
/home/macklin/app/public
/home/macklin/app/site_one
This verifies the path is changed correctly. However, shortly afterward, rails throws the following error (let me know if you need the full trace):
Exiting
/usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/paths.rb:16:in `method_missing': undefined method `javascripts' for #<Rails::Paths::Path:0x7f422bd76f58> (NoMethodError) from /usr/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/action_controller/railtie.rb:47
My guess is it cannot find the javascripts directory even though it is clearly sitting in the "site_one" folder.
Does anyone know why I am getting this?
I know this question is pretty old, but I think I found an answer for this in Rails 4.2.
You just simply have to put this line in your config/application.rb:
middleware.use ::ActionDispatch::Static, "#{Rails.root}/another_public_folder_name", index: 'index', headers: config.static_cache_control
This makes all files in /another_public_folder_name to be served by Rails.
This is the way Rails use to setup the standard /public folder. I found it checking the sources:
https://github.com/rails/rails/blob/52ce6ece8c8f74064bb64e0a0b1ddd83092718e1/railties/lib/rails/application/default_middleware_stack.rb#L24
Duh. Just add 2 more rules for stylesheets and javascripts (I guess they get wiped when you change the parent path)
paths.public.stylesheets = "site_one/stylesheets"
paths.public.javascripts = "site_one/javascripts"