Run Silex from subdirectory nginx, no config access - php

I have an older PHP project on a customer server, with no access to the config files, the server is runner nginx, and PHP 5.4 ...
Is there a way to use Silex Framework or another modern PHP framework from a subfolder? .. e-g. example.com/silexproject/ without access the .config file for the webserver?
is there an nginx alternativ to .htaccess ?

A quick google serach, shows that no, there is not an .htaccess like file for nginx. Quoting the official wiki:
Stop using .htaccess. It's horrible for performance. Nginx is designed
to be efficient. Adding something like this would destroy that.
Keep in mind that you can still use Silex (I imagine that you can use any modern PHP framework as well) you just need to remember to call the front controller every time (so your URLs won't be that pretty).
For example if your project is on http://example.com/projectdir/ your front controller most likely will be http://example.com/projectdir/index.php and if you need to access some resource under that path, you'll need to type http://example.com/projectdir/index.php/path/to/resource (notice the name of the front controller in the URL)
My advice is that you'll try to contact whomever has access to nginx config file and ask if they can change the nginx config.

Related

Change url from localhost/name/index.php to localhost/name/home

I'm trying to change the name from my url's to for example home instead of index.php. I've read you can do that with the .htaccess file but for that you need Apache stuff and I don't have anything like that.
Isn't there any more easy way to change the url?
Yes, there is an easy way to change the URL without using the .htaccess file. This can typically be done by using a web framework or a CMS (Content Management System) such as WordPress, Laravel, or Django. These frameworks and CMSs have built-in functionality for handling URL routing, which allows you to define custom URLs for your pages.
Another way is to use a URL rewriting module provided by your web server software such as IIS URL Rewrite for IIS web server, or mod_rewrite for Apache. These modules allow you to rewrite URLs on the server side without requiring changes to the actual file structure on the server.
Without more information about your web server, it's difficult to give more specific instructions. But you could check the documentation or the community forum of your web server or the language framework you're using to find more information about how to change the URLs in your application.

All URLs are redirected to index.php

I have setup a Symphony framework on my localhost using this tutorial. I am using the PHP default server and MySQL.
The frontend URL is working fine but when I go to the admin URL (http://localhost:8000/symdemo/admin), then my CSS URL is also redirected to the admin page meaning I am not getting CSS code into the response.
The reason as that the default PHP server does not have a URL-rewriting module and index.php is also adding to the CSS path.
How can I fix this?
I'm not 100% sure, but I think you'll find that using a webserver that supports rewrites is quicker than trying to replicate the necessary rewrites in PHP. Rewrites are listed as a requirement in Symphony CMS's readme, and last time I checked Symphony was still dependent on webserver rewrites for some of its routing/files.
You can, of course, use Apache. If you'd like to use a lighter and cleaner webserver that's easy to configure, I recommend Hiawatha, which has a Symphony URL toolkit/rewrite rule set available.

In an MVC framework where should we put our NODE.js files?

I have a PHP framework. Recently I've put some burden on NODE.js shoulders. Now I don't know where to put node.js files. For now I have one file, but It'll get bloated in the near future. Where do you suggest to put these files?
Thanks in advance.
EDIT :
I'm asking to see if putting nodejs files inside the php framework best practice. Or should we put all nodejs file in www folder without ever caring about our PHP framework.
You shouldn't put your node.js code in any web accessible folder (like www), as this is server code and it shouldn't be accessible from the web.
Your best bet is to just make another directory to host your node.js application which isn't in www or any other web accessible directory.
There must be some file named js, javascript, or script somewhere in your root folder. There you should put this file.

Putting another website along with Zend website

I am working with a website built (not by me) on Zend framework.
I have made a small website (for a Facebook app) built on simple html with custom php (no Facebook API used), which, if put in public/ folder (so that it can be reached via *www.main_site.com/my_small_site*), does not work (I get Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration).
The php.ini on the website, however, contains allow_url_fopen = on, so my guess is that all my php files should be simply put somewhere in the application/ folder, instead of the public/ folder.
The websites don't use shared files, they are independent. And purchasing another hosting is an expensive option.
I am absolutely new to Zend, and learning how to make my own controllers/views will consume too much time, so this is the last option to consider.
How can I solve this problem?
Access .php located in application/ from *public/my_small_site/index.html*? (is it possible without touching the main website's public/index.php?)
Create a new view and put my small website there? (how can I make it accessible from the web?)
Still consider new hosting/subdomain options?
Any other solutions?
Thank you!
public/ is the correct place to put your Facebook app. The error doesn't lie - are you 100% sure the php.ini file you checked is the one being used? I'd suggest you create a phpinfo file as explained here https://kb.mediatemple.net/questions/764/How+can+I+create+a+phpinfo.php+page%3F#gs - this will let you view the configuration PHP is using. See what allow_url_fopen is set to there. If it is set to 'off', there might be a different php.ini file you need to change.
Otherwise, contact your host.

Apache Virtual Host pointing to Zend Framework Module

Is there a way to setup apache virtual host so that it root points to a zend framework module?
The address of this module is only a route and there is no physical folder on the server.
Default module:
www.myintranet.com
Another module address:
www.myintranet.com/mymodule/
"mymodule" is not a physical folder, just a route.
I can see no reason why you would ever WANT to do that? ZF2 uses routes to the particular modules which is one of the strengths. By hiding your files outside of the document_root you also get additional security where people cannot try to exploit your php files directly to gain access to your system. In addition to this if your application has multiple modules and there is an issue on one of the modules you can simply disable that module temporarily without having to deal with apache rewrite rules etc.
The direct answer to your question however is that yes you can point apache at your module directory, however you will need to change and update all of the current rewrite rules to deal with the index.php autoloader and PATH related variables. This would be more work than actually learning routing. Once you figure it out it makes your life a lot easier.
I posted an answer here: ZF2 Routing as in ZF1
ON ZF1 -> ZF2 routing as it seems to confuse many people and that router should hopefully get you on your way as I suspect that is the issue you're having...

Categories