Project folder is taken as controller in zend project - php

I am setting a demo Zend project on a windows server.
That is having base url like http://example.com/JPZend/public/
But on some url like http://example.com/JPZend/public/user/index?page=2
it gives the following page not found error where http://example.com/JPZend/public/user runs perfectly.
Page not found
Exception information:
Message: Invalid controller specified (JPZend)
Request Parameters:
array (
'controller' => 'JPZend',
'action' => 'public',
'user' => 'index',
'module' => 'default',
'page' => '2',
)
What am I missing? Seems like some virtual hosting issue?

Normally, you use the public folder as your webroot.
So your URL would look like this: http://example.com/JPZend
The default route in ZF is:
:controller/:action
Or with Modules enabled:
:module/:controller/:action
To tell ZF that you have another Base URL, you need to add a line to you application.ini:
resources.frontController.baseUrl = /JPZend/public
And to your .htaccess or similar under windows:
RewriteEngine on
RewriteBase /JPZend/public
Have fun!

Related

How to setup Yii2 module on subdomain correctly?

I have a project on Yii2 advances app. And I have created a module named 'sale' on front end, Where I have extended layouts of frontend. And now I just want to access that module as a subdomain like http://sale.example.com .
I have created subdomain sale.example.com and set it's document root to root folder public_html (sites's root folder).
I have configures my urlManager like 'http://sale.example.com' => 'sale/default/index', according to Yii2 DOC. And it working fine but all my navigation gone wrong. I mean I think app's homeUrl is not pointing to default site url. My entire url system is changed after sub domains like http://sale.example.com/contact, But this is supposed to be http://example.com/contact . Here is a snapshot.
Thanks in Advance.
You can do it using UrlManager. Here is example Just replace your_module_name with real name of your module. More on UrlManager you can see here
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'enableStrictParsing' => false,
'rules' => [
'sale.example.com/<controller>/<action>' => 'your_module_name/<controller>/<action>',
],
],

Trying to get started with Zend Framework 1.12.7

Hi guys I am having a lot of trouble getting started with Zend Framework 1.12. Basically I've managed to get my project set up in Netbeans and I have it located on my localhost. When I go to this URL I get the default page:
http://localhost/zendtest2/application/views/scripts/index/index.phtml
But when I go to this page I get a list of my file tree in the localhost directory
http://localhost/zendtest2/
I guess what I am trying to understand is how to I get the http://localhost/zendtest2/ to point to the http://localhost/zendtest2/application/views/scripts/index/index.phtml or is that how I would even do it?
I know there is a public folder in my project with an index.php file. Is there some way that I should be reaching that page when the project initially starts?
To me this sounds more like an environment issue rather than a zend framework issue. I am not entirely sure what your dev environment is, but I am going to assume you're using apache as your HTTP server:
https://wiki.apache.org/httpd/DirectoryListings
Again, I am not entirely sure what OS you're using so you'll need to find your httpd.conf file yourself.
You then have two options, adding the redirect/route there (that may be wrong) or (more recommended) uncommenting the httpd-vhosts.conf link:
# Virtual hosts
#Include /private/etc/apache2/extra/httpd-vhosts.conf
Then including the new route in there. Heres a basic example (again you'll need to add what you need):
<VirtualHost *:8888>
ServerName zf2-tutorial.localhost
DocumentRoot "/Users/stevenc/****DIR_STUFF****/skeleton-application/public"
</VirtualHost>
Anything beyond that can be set as your home route in the module.config.php of the Application module within your zend project:
'router' => array(
'routes' => array(
'home' => array(
'type' => 'Zend\Mvc\Router\Http\Literal',
'options' => array(
'route' => '/',
'defaults' => array(
'controller' => 'BookList\Controller\Book',
'action' => 'index',
),
),
),
Also, if you're not using ZF 1.12 for any particular reason, ZF2.3* is the latest.

Common modules in yiiboilerplate?

Is it possible to put and run modules in yiiboilerplate common section?
If it could, how it configured?
Thanks,
Just configure the module with a path alias, as far as I can tell there is an alias root which points to the project root.
'foo' => array(
'class' => 'root.common.modules.foo.FooModule',
),
You may also have a look at this config file from my boilerplate, which does the same.

URL cannot be found on the server for my FuelPHP Module

I'm creating a small FuelPHP application that contains a blog module. In this module the posts controller just assigns a simple view to the template for the posts index.
I have read through the FuelPHP docs and have the following settings in the app config for the modules:
'module_paths' => array(
APPPATH.'modules'.DS,
APPPATH.'..'.DS.'globalmods'.DS
),
'always_load' => array(
'packages' => array(
'auth',
'orm',
),
'modules' => array(
'admin',
'blog',
),
),
The application itself is outside my WAMP www docroot but the assets, htaccess and index.php are inside.
I have no idea why the server cannot find the localhost/blog/posts/index URL as I have followed everything advised on the docs and the homepage (root route) seems to display fine. It is only when I click the blog link (blog/posts/index) that it states
"Not Found
The requested URL /blog/posts/index was not found on this server."
Any help would be much appreciated!
I had the same problem myself. Two key things I did were:
1) Start with a fresh copy of Fuel. I was missing some sort of configuration file, so I create a brand new Fuel framework, and then added all the app files back in
2) Enabling the 'rewrite_module' in the Apache Modules (in the Wampserver config)
Try these two things and see what you get.

Running into couple of issues kohana framework: routing and running on ubuntu 12.04

I've started to learn kohana fews days ago and with my Zend Framework my learning experience seems to be fast until i run into couple of issues.
First of all i started the project in windows 7(dual booting with linux ubuntu 12.04). i know every link was fine before i started adding more pages to an admin app with kendo ui. i've added couple of routes to handle controllers in subfolders and to handle url with query string of the form ?bla=dkll&second=lkdjf (used by kendo grid to send unknown number of params based on users interaction with the grid).
First problem : under windows i would access any url except the root / eg localhost/admin/ (admin being my folder in htdocs) it gives me
ERROR: HTTP_Exception_404 [ 404 ]: The requested URL / was not found on this server :
83 try
84 {
85 if ( ! class_exists($prefix.$controller))
86 {
87 throw new HTTP_Exception_404('The requested URL :uri was not found on this server.',
88 array(':uri' => $request->uri()));
89 }
90
91 // Load the controller using reflection
92 $class = new ReflectionClass($prefix.$controller);
Second problem : Under ubuntu not only i have the same first problem but then i can't even hit other urls like localhost/admin/useraccess/login
Questions:
is the second problem related to the first one (obviously aside the '/' not found one)
i have enabled on ubuntu mod_rewrite and the kohana install page is all green.
is there any other settings i forgot to enable which was enabled in windows php (xampp) that's not on ubuntu?
my .htaccess/logs/boostrap are found here
thanks for reading this and helping out
I assume that root folder of your application is 'admin'. In bootstrap.php you should have:
Kohana::init(array(
'base_url' => '/admin',
'index_file' => FALSE,
));
Also in your bootstrap.php default route should be last route:
Route::set('default', '(<controller>(/<action>(/<id>)))')
->defaults(array(
'controller' => 'index',
'action' => 'index',
));
Other routes that you add should take place above default route.
I have same problem with you, my kohana running well on my windows machine. but when i migrate it to Ubuntu I have a problem with routing. This is my bad, i forgot to edit my apache conf. You can look into conf file in /etc/apache2/sites-enabled/000-default
Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
/Directory>
edit 'AllowOverride None' to 'AllowOverride All' and restart your apache webserver .
Works like magic !!
To add to digby's note: All class file names and directory names are lowercase.
There are a few little things I noticed but nothing that could explain the problem you are having:
Query strings should not be and are not used to route to an action. Use $this->request->query() in controllers to use GET values.
Slashes get trimed off the beginning and end of URI's, so the optional / in the commented out 'def' route is useless.
The second time defining the kendogrid route overwrites the old one. Not that it really matters since they are the same, so why not remove one?
What controller do you expect to be routed too? Currently it should be Controller_... Hmm... I spy with my little eye a typo! 'susbcribers' instead of 'subscribers'. So currently you will be routed to Controller_Susbcribers::index().
If you want the Controller_Useraccess::index() instead of Controller_Subscribers::index() (assuming you fix the typo) remove the first kendogrid route since both 'kendogrid' and 'default' match an empty URI.
PS. I am assuming you use 3.2

Categories