Logging route parameter/request variables - laravel

Currently I'm logging errors in my app/global.php with:
Log::error($exception . ' - ' . Request::url());
For the most part the stack trace is enough to find an fix issues however there are times where I need to know what request variables (post/get) or route parameters are being sent. What is the proper way of retrieving these variables so I can log them for debugging?
Thank you.

You can get all input variables using the Request facade as well.
Request input including files
Request::all();
Request input without files
Request::input();

To help some people out here is the full debug
Log::error($exception . ' - ' . Request::url());
Log::warning('[DEBUG] [Input] ' . implode(' / ', Request::all()));
if(Route::current())
Log::warning('[DEBUG] [Route] ' . Route::current()->uri() . ' - ' . implode(' / ', Route::current()->parameters()));

Related

Laravel Dusk Visit method keeps going back to APP_URL

I have the following on my TimelineTest Dusk file
$browser->visit('/wall/' . $this->username . '/' . $this->userID)
->assertTitleContains($this->username . ' - SiteName');
But although I am specifying the url to visit, my test fails because Dusk still visits the root / and not the url I specified /wall/' . $this->username . '/' . $this->userID
I dumped the current url using
$url = $browser->driver->getCurrentURL();
dd($url);
And it is the correct one, but my assertion fails saying that my title was not found in the page title, which corresponds to the one in the index page /
Did anyone have Dusk not visiting the URL they specified?

File storage not working. Laravel 5

I'm trying to save a .txt file in a folder named txts inside my public folder but the method i'm using is not working:
$txt_nombre = 'nomina_'. $extras['desde'] .'_'. $extras['hasta'] .'.txt';
$txt_contenido = '';
foreach ($personal as $per) {
$txt_cadena = 'BNC ' . $per->cuenta_nomina . ' ' . $per->netos . ' ' . $per->cedula_identidad;
$txt_contenido .= $txt_cadena . "\n";
}
Storage::put('public/txts/'. $txt_nombre, $txt_contenido);
It doesn't even throw an error, my function keeps running but the file is not being saved. Any idea why?
According to the Documentation
By default, the public disk uses the local driver and stores these files in storage/app/public.
Looking at your code, assuming that you haven't changed default configuration, your file should be created in storage/app/public/public/txts/ folder.
I am not sure how Laravel's Storage abstraction handles non-existing folders so you might want, for test, try using just Storage::put('file.txt', "content") and see if it's being created in storage/app/public folder

How can I insert additional libraries to my jdbc/DB2 connection?

I'm writing a little java program to write data in a AS/400 DB2 table via jdbc (db2jcc.jar version 1.0.581) and a trigger is associated to the INSERT operation. This trigger works on various tables associated with libraries different from that (jdta73p10) which contains my table (f4104).
Follows the code I use to establish connection and read data that perfectly runs.
import java.sql.*;
import com.ibm.db2.jcc.*;
public class ProvaNUMEAN13 {
public static void main(String[] args) throws SQLException, ClassNotFoundException {
DB2DataSource dbds = new DB2DataSource();
dbds.setDriverType(4);
dbds.setServerName("a60d45bb");
dbds.setPortNumber(446);
dbds.setDatabaseName("prodgrp");
dbds.setDescription("Prova collegamento");
dbds.setUser("XXXXX");
dbds.setPassword("XXXXX");
Connection con = dbds.getConnection();
Statement stmtNum = con.createStatement();
stmtNum.executeQuery("select * from INTERFACCE.NUMEAN13");
ResultSet rs = stmtNum.getResultSet();
rs.next();
System.out.println("Valore numeratore: " + rs.getString("E13EAN"));
System.out.println("Tipo numeratore: " + rs.getString("K13KEY"));
stmtNum.close();
Statement stmtAnag = con.createStatement();
stmtAnag.executeQuery("select * from jdta73p10.f4101lb where IMLITM = " + "'" + args[0] + "'");
ResultSet rsAna = stmtAnag.getResultSet();
int idCodice = 0;
if (!rsAna.next()) {
System.out.println("Il codice " + args[0] + " non esiste in anagrafica!");
} else {
idCodice = rsAna.getInt("IMITM");
System.out.println("idCodice per " + args[0] + ": " + Integer.toString(idCodice));
Statement stmtQEAN = con.createStatement();
stmtQEAN.executeQuery("select IVALN, IVCITM, IVLITM, IVDSC1 from jdta73p10.f4104 where IVXRT = 'B ' and IVALN = '8000000000000'");
ResultSet rsQEAN = stmtQEAN.getResultSet();
if (rsQEAN.next()) {
System.out.println("Codice EAN per " + args[0] + " giĆ  presente: " + rsQEAN.getString("IVALN"));
System.out.println("Valore EAN13: " + rsQEAN.getString("IVCITM"));
System.out.println("Risultato ricerca per EAN13: " + rsQEAN.getString("IVLITM")+" - "+rsQEAN.getString("IVDSC1"));
}
}
}
}
Problem is when I try to execute an INSERT operation (like that below); an error is generated in AS/400 due to trigger execution.
stmtQEAN.execute("insert into jdta73p10.f4104 (IVXRT,IVITM,IVCITM,IVDSC1,IVALN,IVLITM) values ('B ','18539','8000000000000','Prodotto PROVA','8000000000000','ABABABAB')");
This is the error AS/400 side:
Message ID . . . . . . : RNQ0211 Severity . . . . . . . : 99
Message type . . . . . : Inquiry
Date sent . . . . . . : 08/01/15 Time sent . . . . . . : 10:01:31
Message . . . . : Error occurred while calling program or procedure
*LIBL/PRHWRAPUSE (C G D F).
Cause . . . . . : RPG procedure TRG_F4104A in program INTERFACCE/TRG_F4104A at
statement 152 attempted to call program or procedure *LIBL/WS_MATERI, but
was unable to access the program or procedure, the library, or a required
service program. If the name is *N, the call was a bound call by procedure
pointer.
Recovery . . . : Check the job log for more information on the cause of the
error and contact the person responsible for program maintenance.
Possible choices for replying to message . . . . . . . . . . . . . . . :
D -- Obtain RPG formatted dump.
S -- Obtain system dump.
My question is: how can I specify the other libraries that trigger need? In a old version of my tools (written in Delphi) I used the Client/Access ODBC where there was a special field where you can enter additional libraries but now I don't know how to do.
AS400 (iSeries) allows a comma-separated library list in the jdbc url:
jdbc:as400://someserver;naming=system;libraries=devfiles,prodfiles,sysibm,etc
naming=system indicates sql will use a library list. For example:
select * from NUMEAN13
naming=sql indicates that sql will contain library name prefixed in table references. For example:
select * from INTERFACCE.NUMEAN13
My experience is that you can't mix them. If you use library list (naming=system), then all sql must not contain library names. If you use non library list (naming=sql), then all sql must contain the library names.
There are several ways to handle this. The user profile has a job description and that job description has a library list. I would set up a user profile / job description combination for your JDBC connexion.
If that isn't dynamic enough, consider writing a stored procedure that you can call which will set the library list the way you need it.
Another way is probably too inflexible but I mention it as an alternative. Instead of using *LIBL for the service program, specify the library. On the one hand this makes it impossible to use the same program in test and production. On the other hand, it makes it impossible for someone to insert their own library in the middle.
If you are really stuck and no one on the IBM side is able to make changes for you, you can CALL QCMDEXC as a stored procedure and alter the library list yourself, from the client. This is the least desirable because it means tight coupling between the client and server. If the IBM team ever trues to set up a test environment (or disaster recovery environment!) you will have to change all the references in your client code and distribute the changes to everyone using it.
Thank you for the tips.
I also was thinking to use a stored procedure (as you suggest) but in the end I discovered that using an other IBM package, jt400.jar, is available a DataSource class with a method to set a list of AS/400 libraries that you need to use.
Below how I modified my code (that now works!) using the method setLibraries.
import com.ibm.as400.access.*;
...
AS400JDBCDataSource dbds = new AS400JDBCDataSource();
dbds.setServerName("a60d45bb");
// dbds.setPortNumber(446);
dbds.setDatabaseName("prodgrp");
dbds.setDescription("Prova collegamento a numeratore EAN13");
dbds.setUser("XXXXX");
dbds.setPassword("XXXXX");
dbds.setLibraries("JCOM73P10 JDTA73P10 KLDADBFER KLDADBGAM INTERFACCE SAP");
Connection con = dbds.getConnection();
This class has not available the method setPort but if you use the standard port (like in my case) there are no problems. If will be necessary I'll try to discover how to set it.
Couple solutions.
quick real time fix
Copy the trigger program to QGPL (Temporary fix. A permanent fix would need to be implemented ASAP)
or
Change the JOBD of the user profile used to connect to the AS400 so it has the correct list. The user profile used for JDBC should already be locked down or it's the jdbc of a user in a group so this is a simple CHGJOBD JOBD(x) LIBL(xxx xxx xxx xxx) but the connections will have to be recycled.
or
Change the trigger program so that it has a hard coded library. I'd bet you'd need exclusive access to the file though. I'm not working (no access to iseries) so I can't verify this solution.
I recommend against changing the connection string. You'll end up having to change it for every machine that connects to the database.

Error while uploading in Laravel 4

I'm trying to make a image upload in lavarel 4. The upload passes by
The file "C:\xampp\tmp\phpD1F3.tmp" does not exist
This is my upload code :
$file = Input::file('image');
// Get extension
$extension =$file->getClientOriginalExtension();
// Generate a file name
$fileName = 'pool' . Str::quickRandom();
$fileNameExtension = $fileName . '.' . $extension;
// Process upload
Input::file('image')->move(public_path() . '/uploads/images/app/pools/original/', $fileNameExtension);
`
I don't know why i get this error , please can anyone help me to solve this?
You are probably making some operations on "uploaded" file after moving it to server by move() function. Please make sure there is no operation made on temporary file after calling Input::file('image')->move() function.

Codeigniter's XML-RPC shows no response data

I'm attempting to connect to an XML RPC server with no luck, I am getting an empty response with no debugging information whatsoever. I've switched on set_debug(), but still nothing.
Can anyone tell me why I am getting no response from the server, no error information and no debug information?
$this->load->library('xmlrpc');
$this->xmlrpc->set_debug(TRUE);
$this->xmlrpc->server('https://myurl.com/xmlrpc', 80);
$this->xmlrpc->method('login');
$request = array('param1', 'param2');
$this->xmlrpc->request($request);
echo 'Error: '. $this->xmlrpc->display_error() . '<br/>';
echo 'Response: '. print_r($this->xmlrpc->display_response(), true) . '<br/>';
Even if you type https:// in server method you are still connecting with server via http, look at 2nd parameter - the port you have set is 80.
Just in case.
I forgot to use:
$this->xmlrpc->send_request()
its best used in a conditional statement like:
if ( ! $this->xmlrpc->send_request())
{
echo $this->xmlrpc->display_error();
}
else
{
echo '<pre>';
print_r($this->xmlrpc->display_response());
echo '</pre>';
}

Resources