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.
Related
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.
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!
I'm trying to use this module, https://github.com/gowsram/zf2-google-maps- , but I'm running into a problem.
Zend\ServiceManager\ServiceManager::get was unable to fetch or create an instance for GMaps\Service\GoogleMap
I have followed the instruction in the github readme, and have cloned the project into my vendors directory.
From what I understand, the line which calls the ServiceLocator,
$map = $this->getServiceLocator()->get('GMaps\Service\GoogleMap');
isn't pointing to the right place. Unfortunately my knowledge of how the service locator works isn't deep enough to figure out how to fix the problem, despite attempts to remedy this by diving into the docs. It's all a little over my head.
Thanks for any input you may be able to provide!
Have you edited your application.config.php file so that the modules array contains GMaps? From the look of the error, the module isn't running since the service is not registered with the ServiceManager.
That step appeared to be skipped over in the installation instructions but you should add it to your application config so it runs the module's Module.php code.
application.config.php
return array(
'modules' => array(
'Application',
'GMaps',
),
/...
);
This is because I want to develop a web platform with more than one application in the same project.
In any MVC web application we should have this default URL schema:
domain/controller/action/parameters
1: In Zend, what can I do (in which files) to change this schema to add the application name before the controller name?
Expected Result: domain/application/controller/action/parameters
2: How can I implement the consequences of this new URL block in terms that I will separate the MVC for each application, maintaining the shared resources in a separate directory? What changes may I do in Zend autoloader
Expected Result:
/public_html/
/public_html/platform
/public_html/platform/apps
/public_html/platform/apps/base (user interface container)
/public_html/platform/apps/crm
/public_html/platform/apps/crm/model
/public_html/platform/apps/crm/view
/public_html/platform/apps/crm/control
/public_html/platform/apps/crm/public
/public_html/platform/apps/crm/public/css (and etc.)
/public_html/platform/apps/erp
/public_html/platform/apps/erp/model
/public_html/platform/apps/erp/view
/public_html/platform/apps/erp/control
/public_html/platform/apps/erp/public
/public_html/platform/apps/erp/public/js (and etc.)
/public_html/platform/sys
/public_html/platform/sys/core
/public_html/platform/sys/cfg
/public_html/platform/libs/
/public_html/platform/libs/zend
/public_html/platform/libs/template_it
/public_html/platform/libs/custom
i think it is as easy as having actual different ZF2 application, every one in its own folder, and in the same level, a "vendor" folder where you put all the shared structure (coming from zend, third party libraries, etc).
Then inside the vendor folder, i would create another folder for your own shared code, including all your modules that has to be used by more than one of the applications, so your code is a library for yourself.
Since your app is actually in domain/application, and everyone has it own config, it is very straightforward to have domain/application/controller/action/parameters routes: you just create your normal controller/action/parameters routes, since the app actually resides in domain/application/ and the router doesnt have to care about it.
As you noticed, another problem is the autoloader. YOu just need to update the references to the shared modules inside your application.config.php for everyone of your apps
return array(
'modules' => array( //....
),
'module_listener_options' => array(
'config_glob_paths' => array(
'config/autoload/{,*.}{global,local}.php'
),
'config_cache_enabled' => false,
'cache_dir' => 'data/cache',
'module_paths' => array(
'./module',
'../vendor',//reference to your library modules
),
),
//...
);
of course, if the modules doesnt reside directly inside vendor/module but something like vendor/libraryname/module, you have to take a look at your autoload system (Composer autoloading or whatever) and add the classes or namespaces to the corresponding maps.
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