I have am using Laravel and I am trying to call a single php file via the browser, which is
located in my app path.
I have setup a Route::get to a function HomeController#index
function index(){
include(app_path().'/myphpfile.php');
}
And gets called when doing http://localhost:8888/home/index
This is how I call it atm.
The Problem is my file accepts furthe parameters, which are
processed inside my php file like:
http://localhost:8888/myphpfile.php/user/hello1
or
http://localhost:8888/myphpfile.php/user/hello1/default
So I tried to use Route::any.
It is not working. Can I somehow just tell Laravel to pick up the php file like I mentioned above? Other way then using include?
I donĀ“t want to put this file into the public folder.
Something like wildcard routing.
Thank you for your help.
Related
To register a route, I specify the route in web.php in following way,
Route::get($uri, $callback)->name($name);
Is there any way to do this without any specific callback function?
I am building a laravel website but some portion are made with perl. I need to submit a form to a url where the perl code takes over. However, as the form is used in many places I want to use the $name part as form action inside my front end codes.
Essentially what I want is something like this,
Route::get('cgi-bin/route_to_perl_program.cgi', "DO NOTHING. LET PERL DO IT JOB")->name($url_name);
If you not to define any $callback function,there is no need to define a route in web.php. As you want to use route('name') to produce that url in all your blade file,there is an alternative. You need to add this line of code in your config/app.php as follows:
perl_url => 'cgi-bin/route_to_perl_program.cgi',
And use them in your blade like as
link text
This is not your answer,this might be a solution of your specific
need.
In your $callback function to run a command to execute your perl file and get back the output and return that output as a response.,e.g:
.....
$yourPerlOutPut = exec('perl ~/your/path/yourfile.pl');
return response($yourPerlOutPut);
exec() executes the given command.
You can put your route_to_perl_program.cgi file in public folder and access yourdomain.com/route_to_perl_program.cgi. It will run. You need not put it the route.
Or try something like the following
Route::get('cgi-bin/route_to_perl_program.cgi', function(){
exec('cgi-bin/route_to_perl_program.cgi');
})->name($url_name);
I have successfully removed 'public' from my Laravel project URL.
Now when I include any asset using helper function asset() I have to include public at all places like below.
asset('public/images/a.img')
When I try dumping helper function basepath() and publicpath(), correct values are displayed. How can I avoid writing public all the times in all calls to asset. Is there anyway asset function uses publicpath() instead of basepath().
You have to set your Web Directory on your Web Server to point to
/yourproject/public
it seems like your pointing now to
/yourproject/
I will make subdomain such as Blog by used Wildcard.
but now I use htaccess mod rewrite for call file.php.
I can't use function DB outside view blade. but I want to use function DB in this case. How to I fix this. Thank you so much.
I have a PHP Slim and Backbone.JS setup and all my code is now working without any problems.
The only issue I have is that the code I have is minified into one file with Grunt.JS and is loaded at the bottom of each page.
So my Backbone render call is fired on all my pages within my site and not just the path I want it to run on.
I have now tried to use Backbones Router to fire the render on the path I want it to run on, I did not think this would work and it did not as I am using PHP slim as the routing agent and of course Backbone needs a /#/ route path.
Now when I had this Backbone route set up I did try to get PHP Slim to redirect the /#/ route to the clean PHP Slim route path. PHP Slim did not like this at all, when I use the following code,
$app->get('/#/MYPATHHERE', function () use ($app) {
$app->redirect('/REALLPATHTOGOTO');
});
it gave me a PHP Slim error, it looks like PHP Slim does not like the /#/ route.
So what is the best method for doing this?
I am thinking that I could just call the render function within the PHP page that I am getting PHP Slim to render on my selected route? or is there a better method for doing this?
Thanks
Glenn.
Ok got this to work with Backbone, did some more research and enabling pushState to true on the Backbone.history.start then it works without the need for the hash routing.
Being new to Cake on PHP, I am trying to work out if I have a URL, what would be the easiest way to find the controller code for it?
The URL on my local machine is something like:
http://foofoofoo.local/protected/admin/org/edit/1
I have worked out that the location of the view for this file is at this location on my machine:
/var/www/MyApp/protected/app/views/org/admin_edit.ctp
I thought what I'd do is do a search throughout the entire codebase for anything referencing admin_edit.ctp. I found two entries, and changed them to see if I had found the point where the view is called, but despite changing the file name on these entries - the app still works when I visit the URL: http://foofoofoo.local/protected/admin/org/edit/1
I just want to see where the admin_edit.ctp file is being called within the site.
URL: http://foofoofoo.local/protected/admin/org/edit/1
This means I can assume you have a added a route in your /app/Config/routes.php. Where this is pointing can not be said since we don't have access to this file.
Why can I assume you have added this to your routes? Because the posted URL is not matching the CakePHP Conventions which clearly states that controllers should be defined in plural. Since the URL will be accessing the Controller directly through the Controller, unless a route has been specified, I know that the OrgController does not exist. Why?
Try Inflector::pluralize('Org'). It will return 'Orgs' to you. And thus meaning the controller should be called OrgsController and you should be accessing this Controller via the following URL.
http://foofoofoo.local/protected/admin/orgs/edit/1
In this OrgsController there should be an action (function) called admin_edit(), because you have prepended the org with Admin, which is a prefix.
It can be possible that the /protected part, is part of the URL as well, but do not know where your main /App is located and what part of the URL is pointing to the /app/webroot/index.php file.
The Views can be found at /app/View/Orgs/*.ctp.
If you are still having trouble finding your files. Please start with the Blog tutorial written by the Cake Community. This tutorial describes all the neat built-in tricks and will get your first app running in no-time. Please read that first!
If you are still having trouble, feel free to update your question and add the /app/Config/routes.php file.
Under Cake 1.3, if your application has an AppController (check if the file app/app_controller.php exists), you can put this code in the beforeFilter method:
debug($this->params);
It will print an array on your app pages when you are in debug mode, with the name of the controller and the action used.
Array
(
...
[controller] => controller_name
[action] => action_name
...
)
If the AppController does not contain any beforeFilter method, you can just create it:
function beforeFilter()
{
debug($this->params);
}