I have a php code where I uses sql connections and creating some results. But i don't use any symphony related codes. Where should I deploy those kids of data. At the moment It gives me following errors. But When i run the same code in my localhost WAMP server it works fine.
404 | Not Found | sfError404Exception
Empty module and/or action after parsing the URL "/race/getitemnames.php?eventid=1" (/).
stack trace
at ()
in SF_ROOT_DIR/lib/vendor/symfony/lib/controller/sfFrontWebController.class.php line 44 ...
if (empty($moduleName) || empty($actionName))
{
throw new sfError404Exception(sprintf('Empty module and/or action after parsing the URL "%s" (%s/%s).', $request->getPathInfo(), $moduleName, $actionName));
}
// make the first request
at sfFrontWebController->dispatch()
in SF_ROOT_DIR/lib/vendor/symfony/lib/util/sfContext.class.php line 170 ...
at sfContext->dispatch()
in SF_ROOT_DIR/web/index.php line 7 ...
Please check your RewriteRule.
If you want to do that you'll have to place the external script somewhere beneath your web root, which I assume will be SYMFONY_PROJECT_DIR/web/race/getitemnames.php.
Ideally, you should not put these kind of scripts inside a symfony project. They may open up your project for security risks and other unforeseen behaviours.
I'd suggest to only have your symfony project run at that particular vhost, and if you need to run another framework/script/whatever create a separate virtual host for it with a different web root. For example have your symfony project run from www.mydomain.com, and create a separate host scripts.mydomain.com which will serve stand-alone scripts.
If it is a simple script, you should also investigate if you could rewrite it to run from a symfony action. If possible, create a new module and/or action in your symfony project that executes your script's code. Add a route to it, and you're done.
Also check wether you have set
<directory "path/to/project">
Allowoverride All
</directory>
for your vhost on apache.
Related
I've been working on this for several days now and I'm at the point of pulling my hair out.
Goal: to deploy Slim4 on my LAMP server within a specific subdirectory and accessible via a simple URL.
Structure:
There are several instances of my web app on the server and the setup should be replicated for all of them; the structure is straight forward:
/var/www/company1.com/app
this "app" folder contains the main index.php of the website, as well as other various folders. Eg. /var/www/company1.com/app/index.php => https://company.com/index.php
there is a folder called "api" within which I want to load Slim4. I don't really mind how this folder is structured and how deep it goes. I'm working on basis that this is where the composer file goes.
the end result should be that the customer can access the api by calling https://company1.com/api
I'm using the openapi-generator and the Pet Store yaml file.
Running:
openapi-generator-cli generate -i petstore.yaml -g php-slim4 -o /var/www/company1/api/
I've then run composer install and setup the config.inc.php file as described in the instructions.
However when I navigate to http://company1.com/api I am greeted with the same issue every time:
404 Not Found Type: Slim\Exception\HttpNotFoundException Code: 404 Message: Not found. File: /var/www/company1.com/app/api/vendor/slim/slim/Slim/Middleware/RoutingMiddleware.php Line: 91 Trace: #0 /var/www/company1.com/app/api/vendor/slim/slim/Slim/Middleware/RoutingMiddleware.php(58): Slim\Middleware\RoutingMiddleware->performRouting() #1 /var/www/company1.com/app/api/vendor/slim/slim/Slim/MiddlewareDispatcher.php(147): Slim\Middleware\RoutingMiddleware->process()
it goes on...!
I can't figure this problem out.
This issue seems to be quite common as there are a lot of posts about it, so I'm convinced I've missed something very simple.
I have tried the following:
Setting the base path
$app->setBasePath("/api");
Creating a /public/ folder and moving the index.php file there, then creating two different .htaccess files, based on these instructions:
https://akrabat.com/running-slim-4-in-a-subdirectory/
using basepath as per its instructions
https://github.com/selective-php/basepath
None of it seems to work! What am I doing wrong?
I have been able to successful load the Slim4 Skeleton application, however I want to use the openapi-generator so that I can have it automatically prepare all the php files based on my openapi yaml spec.
Any thoughts on tips would be greatly appreciated!
Using plain old apache server, you make your request to Symfony using localhost:80/acme/app.php/routes
So app.php or app_dev.php is you Front Controller. Knowing this, you can forget almost it. But when you use the PHP built in server, you can access directly to localhost:8000/routes.
I have looked inside the console script file, and it looks like app.php but we call it only once, at the start of the server. Where is the glue stuff ?
The console file is the front-controller for the CLI environment of your Symfony application. The server:run is part of this environment and can be found in the FrameworkBundle: ServerRunCommand (EDIT: as of Symfony 3.3, the command can be found in the WebServerBundle)
It starts the built-in webserver of PHP: php -S localhost:8000 and it routes all incomming requests to a so-called routing script. In case of the dev environment, the router_dev.php router inside the FrameworkBundle.
This router file has this line:
$_SERVER['SCRIPT_FILENAME'] = $_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR.'app_dev.php';
Which pretends that the incomming request was made to the app_dev.php file. (So localhost:8000/something becomes localhost:8000/app_dev.php/something after this router script). It then includes the app_dev.php file to handle the rendering of the site.
I am trying out the trial version of phpStorm 7 with php 5.5.5
When I preview the project in phpStorm ( go to index.php and click on a browser icon in top ), it opens
http://localhost:63342/project/index.php
And I get the default 404 page from Slim Framework. The Visit Home Page targets http://localhost:63342/index.php/ Which results in a 404 phpstorm page.
If I open bash go to PhpstormProjects/project/ and start the native php server php -S localhost:80 and I goto localhost in browser. The project works perfectly as it should.
I would like to be able to use phpstorms preview function instead of having to manual start the native server.
Project overview.
Started empty project, init composer, added `"slim/slim":"2.*" and installed. Added added index.php
Structure
// scroll down for content...
~/PhpstormProjects/project/index.php
// location of slim
~/PhpstormProjects/project/vendor/slim/slim ...
The content of index.php
<?php
error_reporting(E_ALL);
// include composer autoload
require_once('vendor/autoload.php');
$App = new Slim\Slim;
$App->get('/', function() {
echo 'Hello SO';
});
$App->run();
PhpStorm's built-in web server HAS to be accessed via http://localhost:63342/PROJECT_NAME/rest/of/the/path/file.php sort of URL. This is how URL builds automatically.
The key element here is PROJECT_NAME part -- this is how built-in web server detects what project you are working with (comparing to standard web server where such decision will be made based on domain name).
As I understand Slim framework simply cannot handle such URL with extra part in URL (at very least in default configuration), which is expected and understandable.
The bypass such restriction, you have to make few simple manual changes/configurations and you will be able to access your project via http://PROJECT_NAME:63342/rest/of/the/path/file.php URL
Let's assume that project name is slim1.
1. In your hosts file (or local DNS server, if you have one), create an entry that will point slim1 to localhost, e.g. 127.0.0.1 slim1
2. In PhpStorm -- create new Deployment entry (Settings | Deployment) of "In Place" type. Mark it as Default for this project and perform some very basic (and minimal) configuration (like, enter URL you want to use), e.g:
3. Now, when you use Preview file in... or Open in Browser actions on index.php, it will open http://slim1:63342/index.php instead of original http://localhost:63342/slim1/index.php.
P.S.
This applicable to any framework not just Slim.
I am a cakephp newbie and I had trouble to view the files under the view folder through browser.
I used cakephp console to bake model, controller and views. (ex: Invoices_controller.php for controller, invoice.php for model and a invoices folders under views folder). According to the tutorial I read, I can access the invoice view by typing http://localhost/myProject/invoices
(there is no index.php inside the invoices folder..but the tutorial shows it still can display a page. no idea how they did it)
The path for my invoices is myProject/views/invoices and there add.ctp, index.ctp, edit.ctp files inside the invoices folder.
The browser showed the file is not found when I typed http://localhost/myProject/invoices
You have some lack in your knowledge about how the webserver handling a request when cakephp is installed. Assume that we use apache.
In cake's folder structure you can see .htaccess files in the root, app and webroot directories what have url rewrite rules in them. At the end a normal request to a cakephp site will be transformed to a http://site.url.root/app/webroot/index.php?url=original.url
In nutshell to understand it in your point of view:
That index.php call the required php files and at least a cakephp app object is built up in the memory with the required models and methods. Then the app object let say start and calls its methods (model, controller and view methods) and at the end it gives back a result to apache what serves it to you.
Therefore the original url path is a "non existent" virtual url.
If you enter http://localhost/myProject/ do you get a cake intro page? If so does it highlight any problems?
It sounds to me as if you do not have Apache set up properly. I don't know what OS you're using, but it might be worth checking this link, written for Ubuntu, to make sure all is well: http://leoponton.blogspot.com/2010/05/getting-cakephp-up-and-running-on.html
I fixed the same problem.
if you are using windows 7 os, wamp server, cakephp 2.2.3. then
goto apache -> http.conf -> open -> search for mod_rewrite -> uncomment the line LoadModule rewrite_module modules/mod_rewrite.so
Now restart your server, now it should work fine.
Jerry, I think the issue is this. You have put the CakePHP folder in the root of localhost. I would propose that you create a virtual host pointing the myProject so the url becomes:
http://myProject/accounting
This may solve your problem. Be sure rewrite module is on. Also, when you point the virtual host to myProject, it should be the APP folder of the cakephp. If you want to run multiple projects off the same core, you can set them up like so:
/var/www/cake
/var/www/html/myProject
/var/www/html/myProject2
The /var/www/cake directory is where you drop the cake core. Under this directory you will have cake, app, plugins, vendors, etc. the myProject(2) directories will be the contents of the app directory.
Now, to get this to work, you need to go to /var/www/html/myProject/webroot/index.php and edit it to point to the cake directory in /var/www/cake. This will then load the core when rewrite points to index.php in webroot. You should be good to go!
I have installed zend framework on my local machine. I have configured a vhost in httpd.conf and have added a line in my hosts file (127.0.0.1 mysite). I am running windows 7. Everything works perfect. The problem is when i upload on a hosting server the paths get mixed up.
I am uploading on a remote dir called zf-framework. To access the index page i need to type this url: http://mysite/zf-framework/public. It displays the index page but when i press any links on the page they get mixed up and end up being something like http://mysite/controller/action when in fact it should be http://mysite/zf-framework/public/controller/action. I have found a work-around for this situation...to use echo $this->baseUrl(link) for any links i have in the layout.phtml. The problem is more serious when it comes to submitting forms. I can't use baseUrl there....or i don't know how to use it. Is there a way to write some general config stuff so that this could be automatically resolved by the framework. Let's say to write something in index.php or bootstrap.php that will fix the paths automatically?
If you're using Zend_Application, then add the following to your configs/application.ini file.
resources.frontController.baseUrl = "/your-path-here"
If you're not using Zend_Application, then do this in your bootstrap, or index.php file.
$front = Zend_Controller_Front::getInstance();
$front->setBaseUrl('/your-path-here');
You won't have to use $this->baseUrl() when submitting a form to the same action and controller (just leave out the action attribute in the form tag), or when using the Redirector action helper. However, links in your view scripts will require you to $this->baseUrl('/url-without-base'), which doesn't seem too bad to me.
I am not 100% on this, but if you specify the route in your routes.ini as zf-framework/public/Controller/Action etc this should fix your issue.
I would see this as a bandaid, but I am not 100% sure on how to properly fix your issue other then you modifying the vhosts file on the remote server to set a document root to the public folder. If that is not an option, well the above should work, but know that all of your files are potentially accessible from everyone (at least your folder structure). I am not sure what harm this can do (if any) other then if your database schema is in the /data directory.
It is better to try and get the public set as the web root, if possible.