Run PHP scripts stored inside Rails directory structure - php

I built a PHP application using Drupal and I want it to run under the same domain where Rails is running. So for example I have mysite.com running on Ruby on Rails, I would like to install and run Drupal in mysite.com/my_drupal_application.
I tried creating a subfolder inside rails , on the same level as apps and models directories but that did not worked. I tried moving creating a subfolder in the public directory too but it didnt worked either.
Maybe rails is confusing the url to be calling a controller? So what else should i do then?
Thanks a lot!

Both Drupal and rails have their own routing logic. Drupal stores it in both the database and the hook_menu, rails has it defined in the router.rb. They will conflict at some point.
So, the advice is to run your Drupal app on either a different subdomain, defined in a virtual-host. Alternatively you can define vhosts that define urls where your rails and Drupal app run. You should run them next to one another, and never inside one another.

Related

the phonegap directory structure in apache php

I am sorry for this such question as I am still a fresh beginner in Phonegap.
I have followed some tutorial both for the installation and the jquery.mobile usage.
There are some parts (the biggest part) that I am confused with this Phonegap. And it is about the directory structure.
I am working with Private PHP Framework from my department, that is why I used Lamp Stack for all of this.
However, with the Phonegap tutorials I have been following this far, it looks like it have a little bit different environment structure from usual. It have five default directory as follows:
Hook
platforms
Plugins
www
In where the working directory for this Phonegap must be in the www directory.
It makes me afraid because our Apache Environment require us to put the directory in costume folder (Not in var/www), and then also the PHP Framework require us to put the module in a specific folder.
Please, I just need an enlightment for this Phonegap, how do you access the files and where do you guys put it.
Many thanks in advance.
As requested:
Create another vhost that points to www. You don't need to worry about hook, platform and plugins which are cordova/phonegap folders. Let them all at the same level (don't change the structure, just point the vhost to www).
The structure of cordova/phonegap is simple. Inside the www folder will be all your programming logic to build yours mobile app.
But beware, the cordova/phonegap does not compile code in PHP, it just uses a webview (like a browser) to run your mobile application developed with HTML, CSS and Javascript, packaged in a apk with access to native features of the smartphone/tablet, basically.
To make your application to communicate to the server in php you have two alternatives:
1) Making your app to access a URL that points to the application
developed with PHP and render its application in webview.
2) Create all purely on HTML, CSS and Javascript and make
communication via ajax, or socket or something similar to the server.

Laravel multisite with domain mapping

I'm attempting to create a multisite in Laravel, so one codebase but with several sites operating from it. Each site will have similar functionality, so can reuse code, but each site will use a different theme - which I imagine would be as simple as having different themes in the views folder and mapping them depending on the domain that the customer has come through.
I want to be able to access Site X from www.sitex.com, Site Y from www.sitey.com etc, while having only one laravel install and not resorting to any vhosts tomfoolery.
Would any of you be so kind as to advise me on a solution, or to point me in the right direction? I've had next to no luck finding anything so far!
Thanks
If your routing is not going to be too complex you could potentially get away with having numerous public folders
laravel
app
bootstrap
sitex.com
sitey.com
vendor
Then each of your site will be it's own virtualhost with no funky alias rules like so (for security, make sure there is no access to the laravel root dir):
DocumentRoot "/var/www/laravel/sitex.com"
Lastly, you would put a variable in bootstrap/paths.php where the public path will be
'public' => __DIR__.'/../'.preg_match('/\w+.com/',$_SERVER['SERVER_NAME']),
This should work for the majority of deployments even with subdomain routing because bootstrap gets initiated from the index.php file in each of the public folders. If you want to use artisan to load up the built in php server, you will need to provide --host or it will not work. There will be a few limitations on this set up that I have encountered so if someone else knows of a better way I would love to learn how myself.

Eclipse: Share a large framework with multiple projects?

We develop in PHP and HTML/Javascript.
Over time we developed a very big source code library, that contains a couple of hundred PHP and Javascript libraries, that we use for every project. The framework resides its own svn-repository, that we include with an external svn link in each project.
The problem is, that the entire framework itself is about 800MB now.
With only a few projects that we worked on, this wasn't really a problem, but now we have about 30 projects, that all contain a FULL copy of the framework, which takes up a lot of space, and requires constant updating of each copy.
Somehow I would like to have the framework outside the project folders. I've read about referencing other projects in Eclipse, but couldn't really get it to work.
How do you setup the include paths so that each projet 'thinks' that the framework is normally inside the project folder? And can you make a virtual link in an Eclipse project to edit files in the framework just as you would normally do, and get code assist for the libraries too?
One of the main problems is that all our code (and some libraries in the framework itself too) relies on the fact that the framework is in a folder 'framework' inside each project. I'd rather not change all those references to a different path, so maybe I need some .htaccess trick to make this work...
Does anybody else follow the same procedure?
Any advice ?
can you use the "big" project as target platform?
why-create-a-custom-target-platform
If you define it as target platform, the sources are available in your workspace, but they are placed in 1 folder for multiple workspaces. the workspaces will link to the platform, but will not check them out.

Using multiple php frameworks on one website

Our main website uses symfony 1, and by the time I started working on the code it seems impossible to upgrade (too much custom code from previous developer). Now we are adding a large addition to what the company offers. Instead of using a really old framework I wanted to use CodeIgniter, also since I'm very familiar with it. My real question:
What is a proper way of setting up a website to use multiple frameworks. The new features will be separate from the original website, but it will still need a few tables of the database.
I was going to have apache handle where the root directory was depending on the url and just do everything normally. The main website is example.com and the new feature will be abc.example.com
I'm really looking for people who have done this and some tips and warning they had.
PHP will run the framework based on which directory is loaded on the server. For instance, on most apache servers the root directory for example.com would be /www. Which means all of the code for Symphony would be in /www/*.
When you setup the path of your subdomain, just put it outside of the /www folder. Then, when you go to abc.example.com apache won't try to load the original site along with the Symphony framework.
I think it will be fine for both frameworks to share the same database tables. I'm not entirely sure how you plan for these two applications to work, but as long as you don't change the column names and types you should be okay.
If you don't want the applications to share the data in the original table, then look into using mysqldump or something of the like to copy the data over to a new table.

How do you store your scripts for cron jobs in Zend Framework?

Because ZF depends on mod rewrite for all it's URLs, it's not immediately apparent to me where I should store local scripts for use with a cron job.
Does anyone have any recommendations, or is there an "officially accepted" way?
I use the Modular Directory Structure in the design of my websites so that I have controllers, views, etc created for each separate module of my websites. Included within each module I have a scripts (or a cron) directory that stores all of the cron scripts for that particular module.
Personally I find that this keeps things simple when it comes to access resources from Zend Framework as well as from the actual web application.
I had to create a script that would be run via cron (and I was not using modules) so I stuck mine in something like library/Myproject/cronscripts
Here is a pertinent article.

Categories