Symfony same webservice working on Databases - database

Here is the issue:
I have some methods in action in a Symfony project that are defined in WSDL.
I need a configuration where my ws can work on one of two data bases according to environment.
I tried defining different environments and even different applications.But they all insist to use the DB from the databases.yml under the config on the level of apps.
I really appreciate any help

In order to select the database connections dynamically you can use the same technique demonstrated in this slide
http://www.slideshare.net/kriswallsmith/symfony-in-the-cloud

Related

How to develop a simple database based project

I want to start an information provider service. It works this way:
Some employees will find the information needed and fill a database manually.
Users will request data they need on their client side apps on their own platforms. Some of the project specifications is as follows: 1) Data that will go between database server and clients is really small(Suppose some ordinary images). 2) The client side apps don't need to be kept updated. Once the user of app clicks update button(for example) the app will request the server to send required information. 3)It's important to run client side apps on several platforms like: windows, windows phone, android, ios,... 4) Database doesn't need to be vary fast or vary big.
Note: And It's important to note that I'm not expert and I have some limitations. I know java and html, css, javascript. But I think those are enough for this project. (Am I right?)
So I decided to design this development architecture:
1)Using hibernate and provide a layer for server which stands above hibernate and is used to do database-specific tasks. This layer provides some protocols for client side apps to communicate with server. It enables me to change database later without changing client side apps. 2)Using PhoneGap which is a framework that uses html, css, javascript and produces apps for many platforms.
I really appreciate any suggestion, comment,... Thanks!
The fastest way in Java world would be spring boot. Basically you can configure whole application: datasource, orm, persistance layer and rest services just by adding proper annotations. There are many examples of how to do it. Basically with current implementation of spring jpa and web services you can bind mapped resources to rest services. Also current JPA can generate SQL for you using DAO method name. SO e.g. findPersonByName will generate proper sql for you (of course you need to map your db model in entities but this is also simply done with annotations).
Yes, this is a sufficient tech stack to accomplish your goal. You will have to decide how much logic to implement server-side vs app-side.
Pick a java framework for providing an API so that you can expose a restful API to your apps.
Here are a couple of comparisons from stack overflow:
Which is the best Java REST API?
Easiest frameworks to implement Java REST web services
no! for database you need server side scripting language, like php or perl, java-script is client side and will only work on browser. i recommend first learning mysql database, just the basics how to create Db, table, insert and fetch. then some PHP. i think these will set the ground for your project. '
for development environment : download XAAMP! it comes complete with Sql-database base and PHP.

CodeIgniter Multi-site Setup

I am trying to create multi-site platform using codeigniter.
Requirements are:
- Same Codebase.
- Same Database.
Just wanted to know how to achieve multi-site platform if we use same database/codebase?
Is there any way we can create separate tables for each new site i.e wordpress multisite?
Thanks a lot.
For separate sites you have to create separate directories, and set paths accordingly
eg.
application/contollers/site1/index.php
application/contollers/site2/index.php
Same for views and models
For database you can use prefix,
eg: if u are creating same site in different languages
eng_title
arabic_title
eng_description
arabic_description or arb_description
and you can fetch your desired data with your query and condition.
CI tutorial would be helpful for your requirements, please check
Running Multiple Applications with one CodeIgniter Installation

CakePHP create folder in controller? [Need Expert Advice]

How is it possible to have folder in controller?
For example this scenario: We have multiples clients and each clients might have different package that share the common controller or different controller based on their own request. So I was thinking to separate them by directory in the controller.
Any Expert in Architecture can help this?
This is probably possible, but is certainly not the way you should do things with Cake (or MVC in general, probably).
I suggest that you have a separate app for each client. If you have any specific questions regarding this, or would like to add more information to your question about what you're trying to do, I can try to give you a more in-depth answer.
Without knowing more it is hard to say.
I assume you have one app that is used by multiple clients through subdomains or something else to make a difference between who is using it.
You can have a plugin per client that extends the base apps controllers as needed. You also can have different models and views then. Use routes to make the different named controllers match always the same URLno matter what client is logged in.
I would prefer a one app solution over multiple applications because it reduces the maintenance overhead a lot. But if you want to for multiple apps I would build the core of the application that is shared by all sites as a plugin itself. Using git and submodules you can then even control what version of the core module each site is using.

Will Service Reference from Sandbox WSDL work on Production endpoint given there are some differences between the two environments?

Let's say I have both the Production and Sandbox environments.
There are differences between the two - let's just say Sandbox has more modules installed, or the other way around.
I then generate a WSDL from Sandbox, add the Service Reference based on that WSDL and proceed to code up my application in .NET. The .NET application however uses only the methods which would be common to both Sandbox and Production environments, such as login(), query(), using the standard objects such as Lead etc.
Can I simply change the endpoint to point to Production and expect what I coded to work?
Yes. If the methods you are calling has same signature in both environment, nothing will cause the problem. If you alter the signature of the methods in service contract, that will cause runtime exception.
Also I would like to comment, if you change (ONLY addition of new members) the data contracts for these Service Methods, it will also work fine. For this to work, your service needs allow ExtensionDataObject. Any extra data from client will be stored in this object on the server.
Hope it answers your question.
As far as I'm aware, if you're only dealing with the standard API calls then yes, changing the end point should be enough. Of course you need to make sure you use the appropriate credentials and security token too!
When you create extra webservices via apex, they have their own WSDL to describe them — if you're using one of those then it should be the same for both environments if the methods are the same. As for custom objects etc., they're supported by the standard WSDLs.
For the sake of completeness, the Partner.wsdl is designed for connecting to different orgs rather than a specific one, so it is identical across environments and it's loosely typed, this may be the best one for your purposes.
A loosely typed WSDL for customers, partners, and ISVs who are building client applications for multiple organizations. It can be used to access data within any organization.

nodejs and database communication - how?

I've heard much good about nodejs and writting client-server application with it. But I can't get, for example, when developing IM client-server application, how nodejs server script is supposed to talk to database server to actually store it's data? Or may be I miss something and nodejs server scripts are not supposed to do that? If so, please, push me to correct direction.
I've noticed DBSLayer http://code.nytimes.com/projects/dbslayer/wiki, but it looks like it's still in beta.
You need to grab a module that handles the communication to the database you want. See here for a list of modules for node.js. Popular databases that work well with node.js are MongoDB, CouchDB and Redis.
As stagas says, you can use a module that handles communication if you want to use an external database.
If you want an internal (=embedded) database, you can use one written in javascript you can require like any other module such as NeDB or nStore. They are easier to use and useful if your webapp doesn't need to handle a lot of concurrent connections (e.g. a tool you make for yourself or a small team), or if you write a desktop app using Node Webkit

Resources