Reputation: 1536
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);
Upvotes: 1
Views: 526
Reputation: 2932
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);
Upvotes: 0
Reputation: 1125
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
<a href="{{ config('app.perl_url')}}">link text</a>
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.
Upvotes: 1