FuelPHP custom environments - fuelphp

I'm moving an existing FuelPHP application across to a new environment, and I've reached the point where I could really do with adding another environment beyond the default 4 (ie. development, test, stage, production), which are all already in use elsewhere.
Is there any reasonably straightforward way of adding an extra environment to FuelPHP? If there is, I'd appreciate any guidance on how to do it.

Yes its possible but its not documented any where , here is the hacked approach that I found after looking at your posting
Below are the steps to create custom environment in FUel php application
for example you need to call your new environment as 'experiment' then
1 . Create a folder called experiment inside fuel/app/config directory
2 . create db.php file inside fuel/app/config/experiment directory with below contents you can add your other config but below are the default DB configurations ( change it according to your platform ) also other migration files could be copied to this folder from other environment
return array(
'default' => array(
'connection' => array(
'dsn' => 'mysql:host=localhost;dbname=yourappdatabasename',
'username' => 'yourDBuname',
'password' => 'yourDBpassword',
),
),
);
3 . Next change the env name inside Fuel/app/bootstrap.php file
Fuel::$env = (isset($_SERVER['FUEL_ENV']) ? $_SERVER['FUEL_ENV'] : Fuel::EXPERIMENT);
4 . Then open Fuel/core/classes/Fuel.php file and add a new constant to Fuel class like below at the top of the class , I think you could find other environments also declared there .
const EXPERIMENT = 'experiment';
And that's all you have created a new custom environment in Fuel php application ,
NOTE : - this approach is a hacked approach not officially documented
any where
Posting here by hoping it may help you or others with similar
requirements
EDIT : - This is for versions > 1.5
Step 1 and step 2 are same
3 . (Assuming you're using Apache) set FUEL_ENV server variable to your new environment name by adding the following line to your VirtualHost configuration:
SetEnv FUEL_ENV experiment
That's all there is to it (on Apache, anyway). No need to add a const to core/fuel.php (as per the pre-defined environments). This is unnecessary and will only make it difficult to upgrade Fuel's core.

Related

How to reconfigure rails 4 to use mongodb

I want to configure my existing rails application to use mongoid instead of a sql database. Ideally, I would have used "rails new --skip-active-record name_here." How do I do this after I've already made an application? I haven't done anything with the model or database yet so there are no files that i created relating to the database aside from what was made when I created the rails project.
You can start by manually removing references to ActiveRecord::Base in your model files and replace them by include Mongoid::Document
You might also need to comment every line starting by config.active_record in your environment configuration files.
You'll find these files in /config/environments/
Then you can use the rails g mongoid:config command to generate the mongoid.yml configuration file.
PS : When using rake you'll have to use rake db:mongoid:* commands.
EDIT:
Also remove require rails/all
You'll have to require each framework separately, for example :
require "action_controller/railtie"
require "action_mailer/railtie"
require "sprockets/railtie"
require "rails/test_unit/railtie"
The complete list of frameworks included in rails/all is here :
active_record
action_controller
action_view
action_mailer
active_job
rails/test_unit
sprockets
You can also disable all migration check in test/test_helper.rb

How to modify configuration properties in Mean.js?

I am currently working in a cloud environment (cloud9) and have installed the Mean.js (http://meanjs.org/) package.
Following the tutorial at IBM (http://www.ibm.com/developerworks/library/wa-mean1/index.html) the final step involves running the application using grunt.
Now in order to run the default application I need to change a couple of properties as I am using a Cloud Database (MongoLab).
My question is how I can change the properties, such as config.db, in the mean.js? On their website they describe the following: http://meanjs.org/docs.html#configuration
However, there is no clear explanation in which file to do so or how to do it?
When inspecting the code, you will probably see several environment definition files (production, development etc). Those contain the mapping for the config variables, example:
db: process.env.MONGOHQ_URL || process.env.MONGOLAB_URI || 'mongodb://' + (process.env.DB_1_PORT_27017_TCP_ADDR || 'localhost') + '/mean',
so parameters are expected to be defined as environment variables.
For setting up mongodb you can specify either MONGOHQ_URL, MONGOLAB_URI or the DB_1_PORT_27017_TCP_ADDR, for facebook App ID it looks for: clientID: process.env.FACEBOOK_ID || 'APP_ID' etc.

change config/newrelic.yml path

I'm using the new relic ruby agent with symfony 2.1 and capifony.
I'd like to be able to tell the new relic agent that the config file lives under app/config/newrelic.yml instead of config/newrelic.yml
Is this possible?
You have to set NRCONFIG environment variable and you can do it directly in cap call this way:
cap newrelic:notice_deployment NRCONFIG=app/config/newrelic.yml
I would like to set it in deployment configuration and according to cap documentation this should work:
set :default_environment, {
"NRCONFIG" => "app/config/newrelic.yml"
}
but it doesn't. ;o(

CherryPy : Accessing Global config

I'm working on a CherryPy application based on what I found on that BitBucket repository.
As in this example, there is two config files, server.cfg (aka "global") and app.cfg.
Both config files are loaded in the serve.py file :
# Update the global settings for the HTTP server and engine
cherrypy.config.update(os.path.join(self.conf_path, "server.cfg"))
# ...
# Our application
from webapp.app import Twiseless
webapp = Twiseless()
# Let's mount the application so that CherryPy can serve it
app = cherrypy.tree.mount(webapp, '/', os.path.join(self.conf_path, "app.cfg"))
Now, I'd like to add the Database configuration.
My first thought was to add it in the server.cfg (is this the best place? or should it be located in app.cfg ?).
But if I add the Database configuration in the server.cfg, I don't know how to access it.
Using :
cherrypy.request.app.config['Database']
Works only if the [Database] parameter is in the app.cfg.
I tried to print cherrypy.request.app.config, and it shows me only the values defined in app.cfg, nothing in server.cfg.
So I have two related question :
Is it best to put the database connection in the server.cfg or app.cfg file
How to access server.cfg configuration (aka global) in my code
Thanks for your help! :)
Put it in the app config. A good question to help you decide where to put such things is, "if I mounted an unrelated blog app at /blogs on the same server, would I want it to share that config?" If so, put it in server config. If not, put it in app config.
Note also that the global config isn't sectioned, so you can't stick a [Database] section in there anyway. Only the app config allows sections. If you wanted to stick database settings in the global config anyway, you'd have to consider config entry names like "database_port" instead. You would then access it directly by that name: cherrypy.config.get("database_port").

Accessing development , testing sites using different DB in Zend framework

Hi Zend framework guys,
I have a question for you :
There is production , development , testing etc that we can set .
I assume we have 3 different db for these .
But I have a doubt how do we access the url for testers and developers ?
Do we need to pass as a GET value and set whether its development , or for testing ? Or is there any other way ?
http://localhost/ is the url and I am the developer who uses it, How do we give the url for testers ? I am not a server admin , so if you guys have some other techniques using the same code base ?
Or do I want to have 3 code base itself for testing , development , production etc . For production its OK :) , but just an example .
The question was asked by some of my friends when I introduced them #ZF , but I was not sure whether I am right when passing it as a GET value and setting it .
ie like site/?version=dev or something like that :) . If you have an answer I love to hear .
Edit :
I was looking for a way like #David Weinraub says "Are you saying you want to use a single virtual host, a single location, but be able to force the execution context into dev, testing, production mode? That's kind of unusual."
Answer by #Iznogood is also right . But I was looking for a way #David Weinraub says . So marking it as correct for its a kind of unusual.
Thank you guys for your helps.
Are you saying you want to use a single virtual host, a single location, but be able to force the execution context into dev, testing, production mode? That's kind of unusual.
If not, that is, if you will deploy dev, testing, production to different servers and (which strikes me as the more common arrangement), I agree with #izogood: Issue your SetEnv directive either in .htaccess or upstream at the vhost level.
Since many of my projects don't have a formal "build process" - just a straight FTP upload, often to shared hosting; kind of basic, I know - I prefer to keep my .htaccess free of deployment-specific content. As a result, I tend to issue the SetEnv directive at the vhost level on my local dev machine, and then let the APP_ENVIRONMENT constant - defined in public/index.php - default to 'production'.
in your .htaccess if you use one thereshould be
SetEnv APPLICATION_ENV production
Wich is where you would switch between the different environment.
So on your stagin server its
SetEnv APPLICATION_ENV staging
on your dev server
SetEnv APPLICATION_ENV development
etc...
Assuming you setup your db in application.ini.