Problems while Developing MVC Projects using WAMP server - php

I am trying to develop websites using Zend Framework. But I came to a strange problem, the public folder is not showing up. I was suppose to change the apache's configuration to redirect http://localhost/ to http://localhost/public, but there are many projects inside the WWW folder, which has to be accesed.
I can enable the mod_rewrite to bring out the public folder, but I am not allowed to change it while I upload it to the actual web server. Is there anyway to solve this problem?
May be a .htaccess file to change the site root folder would be of help.

This answer is a detailed description of manually setting up your virtual host and configuring a basic ZF app to run. Hopefully it will help.
Update: Given your edited question, perhaps my blog post discussing one approach to deploying a ZF app on shared hosting might be helpful.

Related

Problems when moving Symfony3 app from dev to production server

I've created a web application using Symfony 3. In the development environment, I always use Symfony's built-in server and just use the command "php bin/console server:run". The app can then be accessed via "localhost:8000".
I've also defined routes using annotations in Controllers such as "/", "/about" etc. These pages can be accessed via "localhost:8000/" and "localhost:8000/about". Other links on the page that point to routes like "/contact" or "/users/1" also work perfectly. They will link to "localhost:8000/contact" and "localhost:8000/users/1".
Now, I move my application to the production server. On the production server, Apache2 is installed and some other people have developed Symfony applications on it. Their apps can be accessed via url like "example.com/apps/app1/web/app_dev.php" and the links on their apps have been pre-appended with "example.com/apps/app1/web/app_dev.php" automatically. So when the user clicks a button that links to "/contact", the link will direct to "example.com/apps/app1/web/app_dev.php/contact".
Now, when I move my application named "app2" under the "example.com/apps/" directory, I can visit "example.com/apps/app2/web/app_dev.php" without any configuration and see my homepage perfectly. Apache can automatically pick up my code. However all the links on the homepage will direct to "example.com/contact" instead of "example.com/apps/app2/web/app_dev.php/contact".
Can anyone help me with this? I'm pretty new with Symfony and Apache.
Or perhaps I've done the migration from dev to production environment in a totally wrong way? Any new ideas or proper way to move Symfony3 application to production server?
Thanks a lot!
Do you have apache configured correctly? You may need to have a virtualhost configuration added to the server. You can find out about it on the Symfony site for the specifics.
I finally solved the issue. I should use href="{{ path('about') }}" instead of href="/about" in all twig templates. Thanks everybody!

Using laravel in a subdirectory, without root access

A year ago, I decided to go with codeigniter instead of laravel, because codeigniter prooved to be easier to setup. I am now preparing for my next project and it seems as if codeigniter is now obsolete (at least most of the people seem to recommend laravel over codeigniter).
Now to my problem: I use a virtual ubuntu machine for developing web apps so I have a dev environment similar to the production environment (this helps me to avoid some problems (especially case-sensitivity...;)))
I installed composer and laravel and created a new laravel project named "quickstart" in /var/www/quickstart. I then followed their "getting started guide" (here: Guide). So far everything worked.
But here come the problems:
I have two other web applications in /var/www, so when I enter the ip of the machine I see the 3 directories.
Issue 1:
Normaly I'd expect that as soon as if I click on the "quickstart"-Directory in my browser, the webapp would get displayed, but I have to click a second time on "public", and then the webapp is displayed.
Issue 2: Of course, the links on the page are wrong too, because they reeer to (for example) "/task", which can't be found on the server.
The problem is that I'm not really experienced with apache configuration. I suspect it has something to do with VirtualHosts, but AFAIK you need to have root access to configure virtual hosts, and I do not have root rights on the dev environment.
Could you point out a way to me how I can make laravel work in a subdirectory in a way that I can just move the files and folders to my hoster as soon as I have finished the project? I'd like to then change only one file, and not all paths and URLs in all files ;)
Regards,
Christian
Thanks to Bogdan, I was able to figure it out. My hoster allows symlinks, so I did it like so:
I put the laravel installation in
/srv/web/quickstart
(quickstart is the name of the project). I then created the following symlink:
ln -s /srv/web/quickstart/public /srv/web/www/public
The document root of the apache is configured to
/srv/web/www/public
After that I just got a blank page. That was because I forgot to set the correct permissions on the storage-folder. So I set the following permissions
chmod -R 777 /srv/web/quickstart/storage
This is fine for a development environment. For production I'd recommend to only allow the webserver-user to write into that directory.
And voilĂ : Everything works!
Thank you for your help bogdan.
Christian

Laravel 4 - Local to Staging 404 issue

I hope that this isn't too broad a question but I have been developing a site locally for a month or so and am ready to put it up on my staging server. The deployment all went smoothly after a little issue installing Mcrypt but all is good now, except for in my staging environment I get a 404 on every route.
They way my application is structured is I have folder in app that contains each of my modules, each module (Users, Auth, Teams etc.) each have their own routes.php file aswell as controllers/models/repositories etc.
If I access the site using say /login I recieve a 404, however, If i was to quickly create that route in the main routes.php file in app/ it works which is leading me to believe that for some reason the server isn't loading the individual modules files.
Can you give me a hand narrowing it down, what sort things should I look at etc?
Thanks in advance.
Ok so I found out the issue.
For some reason my local (homestead) environment wasn't too bothered about case sensitivity, however, my staging server was. A few tweaks and I am up and running, cheers for the ideas though :)

install zend framework without apache virtual hosts

I have my website in /var/www/invent. I have zend-framework in /var/www/invent/library.
Basically what i want is when i access http://localhost/invent to work as if i had a virtual host "invent" defined in apache conf file (like accessing http://invent). How can I achieve this?
I have developed my project under windows, having virtual hosts set up but I don't want to continue working like this because i cannot deploy my app on public webhosting services that do not allow me to create virtual hosts. Not to mention that if I deploy an app on a LAN, i need to configure the client's hosts file as well...
Please help, this is the most annoying thing with zend (haven't tried other frameworks so far though).
Your application document root is wherever you place your index.php file, the locations of the Zend Framework library and your application code are irrelevant.
Provided you've used the BaseUrl helper in your views for static assets (JavaScript, CSS, images) and the Url helper for action links, your application should be very portable in regards to relative path from the web server document root.
Let me know if I'm way off track here. Your question could do with some more details.
remove vhost property and go directly to http://localhost/yourproject/public folder. You will need to stay with htaccess mod_rewrite , don't delete mod_rewrite properties in htaccess

Zendframework link problem

I am very to new to zend frame work , I am trying to set up a project (Done by other programmer) in my local server, but in this project the all links to another are not working?
Plss help me!!!!!!!!1
I don't know where exactly relies your problem but it could be several things
make sure the rewriting is working
properly (Apache settings, IIS
settings, .htaccess). You check that
by adding a die('I am in
index.php'); in your index file and
browse some urls
$frontController->setBaseUrl if your website is not at the root of the server your should set the baseurl to match that.
That's the two main reason that come to my mind now I would be glad to help more if you give more details...
Just a guess. Since I had a problem that is a bit like this. You may need to set up your virtual host for this one. Maybe the old developer used a certain virtual host. That is why it is not working when you transfered it to your local machine
Check your VirtualHost settings, then check .htaccess or post this files.

Categories