I have set the Lumen working. The debugging when hitting on a wrong route it gives a proper Laravel error log. However, when I try it with a Post route and it gives an 500 Internal Error, the page in network is blank. Chrome says This request has no response data available
My .env is
APP_ENV=local
APP_DEBUG=true
APP_KEY=SomeRandomKey!!!
I am not sure if it's related with the host but I am using nginx with Digital Ocean.
I tried adding this in public/index.php, but no luck..
try {
$app->run();
} catch(\Exception $e) {
echo "<pre>";
echo $e;
echo "</pre>";
}
What may be the problem
Edit: The function I am trying to call:
public function index(Request $request) {
$a = $request->all();
foo($a)
}
private function foo($a) {
print($a)
}
Try this:
public function index(Request $request)
{
$a = $request->all();
$this->foo($a);
}
private function foo($a)
{
print_r($a);
}
Related
hello i want to update my data in DB using V-form but 500 internal server error show:
this is my function in controller:
public function update(Request $request, $id)
{ $data =$request->all();
//
$client = Client::where('id', $data['client_id'])->first();
DB::table('projets')->where('id',$id)->update(['name'=>$data['name'],'durre'=>$data['durre'],'description'=>$data['description'],'owner'=>$client->name,'budget'=>$data['budget']]);
}
and this is my route:
Route::apiResource('projet' ,'API\ProjetController');
and this is the vue code:
modifier(){
this.form.put('api/projet/'+ this.form.id).then(function(){
$('#AjouterProjet').modal('hide')
seww.fire(
'Modifier!',
'Your User has been Updated.',
'success'
)
fire.$emit('ajoutprojet');
}).catch(function(){
})
},
In your route specify the Controller function to execute like this
Route::apiResource('projet' ,'API\ProjetController#update');
When you get 500 error, Check the last file on storage/logs directory and try to find the last error on this file, errors are in this format:
[date_time] [error_message] [stacktrace]
I'm trying to send mail with SendGrid, picking up the email that the user wants to send and the message, but I'm having this error when i try to submit:
Failed to authenticate on SMTP server with username "João Gabriel" using 2 possible authenticators. Authenticator LOGIN returned Swift_TransportException: Expected response code 250 but got an empty response in ...
My Mailable:
public $remetente;
public $nome;
public $destinatario;
public $data;
public function __construct($remetente, $nome, $destinatario, $data)
{
$this->remetente = $remetente;
$this->nome = $nome;
$this->destinatario = $destinatario;
$this->data = $data;
}
public function build()
{
//$address = 'janeexampexample#example.com';
$subject = 'This is a demo!';
$name = 'Jane Doe';
return $this->view('emails.test')
->from($this->remetente, $this->nome)
->subject($subject)
->replyTo($this->destinatario, $name);
}
}
My Controller:
public function enviarEmail(Request $request){
$destinatario = $request->input('destinatario');
$mensagem = $request->input('mensagem');
$remetente = \Auth::user()->email;
$nome = \Auth::user()->name;
Mail::to($destinatario)->send(new TestEmail($remetente, $nome, $destinatario, $mensagem));
}
Can someone help me?
Your error message indicates that there is something wrong with the authentication on the SMTP server. There seems to be nothing wrong with your code.
Maybe inspect the error message better, there might be a specific log message somewhere down the stacktrace maybe?
Have you verified your credentials to be correct? Have you verified host and port? Check your .env file and the config/mail.php to see if your settings are correct.
I use pacakage :: https://github.com/Shivella/laravel-bitly
I try to create bitly link 5000 link but It's always error :The response does not contain a shortened link
public function test(Request $request) {
if ($request->isMethod('post')) {
$barcode = Barcode1::whereNull('shortlink')->get();
foreach ($barcode as $b) {
$url = app('bitly')->getUrl('https://www.test.com/shrotern/'.$b->encode);
$update = Barcode1::find($b->id);
$update->shortlink = $url;
$update->save();
}
}
return view('test');
}
How can I fix this
It's work fine on a real domain or you can create a virtual host.
Here is my controller code
function index() {
echo $this->session->flashdata('message');
$this->load->view('categoryView');
}
function delete() {
$products = $this->item_model->get_category_id($category_id);
if (count($products)) {
$message = 'Category Name is used by the product. Please change them to another category!';
}
else {
$category_id = $this->product_category_model->delete($category_id);
$message = ($category_id) ? 'Category Deleted Successfully' : 'Failed to Delete Category';
}
$this->session->set_flashdata('message', $message);
redirect('category', 'refresh');
}
After calling the delete function the flashdata has to be set and retrieve that value in index() function of the same controller but I can't.
Am also tried the $this->session->keep_flashdata('message'); before redirect to index function. But still am not get any value in index function.
Also changed $config['sess_expire_on_close'] = FALSE; to $config['sess_expire_on_close'] = TRUE; Still am not get the result.
I am wasted more time(nearly half day). Please anybody help to retrieve the flas data in codeigniter.
There are several probabilities:
1- Check your browser cookie. See if it allows cookies or if any other extension is intervening.
2- Refresh might not send the browser a new request (which thus mean a new URL). Try it for another controller see if it make any change
3- hard code the set_flashdata() with hard-coded value than a variable. set_flashdata("message", "Thank you");
In codeingitor you cannot echo anything in controller.
You have to set in $this->session->flashdata('message'); in view file not in index() function of controller
Try again by putting $this->session->flashdata('message'); in "categoryView" file where you want to display flash message.
You could try:
function set_flashdata_notification($notify_type, $msg, $error_code = null)
{
$ci =& get_instance();
$flashdata_data = set_notification_array($notify_type, $msg, $error_code);
$ci->session->set_flashdata($flashdata_data);
}
function delete() {
$products = $this->item_model->get_category_id($category_id);
if (count($products)) {
set_flashdata_notification('Category Name is used by the product.','Please change them to another category!');
redirect('path_to_view/view','refresh');
}
Trying to run Codeigniter User Guide XML RPC Sample Code.
This is the code
xmlrpc_client.php
<?php
class Xmlrpc_client extends CI_Controller {
function index()
{
$this->load->helper('url');
$server_url = site_url('xmlrpc_server');
$this->load->library('xmlrpc');
$this->xmlrpc->server($server_url, 80);
$this->xmlrpc->method('Greetings');
$request = array('How is it going?');
$this->xmlrpc->request($request);
if ( ! $this->xmlrpc->send_request())
{
echo $this->xmlrpc->display_error();
}
else
{
echo '<pre>';
print_r($this->xmlrpc->display_response());
echo '</pre>';
}
}}?>
xmlrpc_server.php
<?php
class Xmlrpc_server extends CI_Controller {
function index()
{
$this->load->library('xmlrpc');
$this->load->library('xmlrpcs');
$config['functions']['Greetings'] = array('function' => 'Xmlrpc_server.process');
$this->xmlrpcs->initialize($config);
$this->xmlrpcs->serve();
}
function process($request)
{
$parameters = $request->output_parameters();
$response = array(
array(
'you_said' => $parameters['0'],
'i_respond' => 'Not bad at all.'),
'struct');
return $this->xmlrpc->send_response($response);
}}?>
After this, i ran the url like this.
remoteserver's ip/xmlrpc_client
(i deleted my index.php using .htaccess, dont need to type it)
the result is like this,
Did not receive a '200 OK' response from remote server. (HTTP/1.1 404 Not Found)
If i run the server code,
remoteserver's ip/xmlrpc_server
it says like this.
This XML file does not appear to have any style information associated with it. The document tree is shown below.
Which means,
$this->xmlrpc->send_request()
this request have been failed
and echoed
echo $this->xmlrpc->display_error();
Any idea what is the problem is?
Oh, i have another question.
Do i have to install xmlrpc php extension before i use this codeigniter xmlrpc class?
Solved! the problem was the remote sever's firewall.