How to update Magento 2

Try the CLI update process:

1) On your terminal go into magento root folder.
2) Set magento 2 under maintenance mode

php bin/magento maintenance:enable

3) Search for the correct and latest magento 2 version

composer show magento/product-community-edition 2.3.* --all | grep -m 1 versions

4) Force your composer to use the latest version

composer require magento/product-community-edition=2.3.3 --no-update

5) Update your magento 2 installation

composer update

6) After successful update Upgrade magento and compile

php bin/magento setup:upgrade
bin/magento setup:di:compile

7) Disable maintenance mode and you are ready to check the correct version

php bin/magento maintenance:disable

from: https://community.magento.com/t5/Magento-2-x-Version-Upgrades/Upgrade-from-2-3-1-to-2-3-2-security-updates-correct-version-not/td-p/135324

How to read file content in Public folder with Laravel

If you want to read the content of a file in the public folder using Laravel, you can use this code

$file_name = "test.dat";
$file_url = 'public\subfolder\\'. $file_name;
$content = file_get_contents(base_path($map_url));

base_path is a helper function to generate a fully qualified path to a given file relative to the project root directory

How to view latest SQL statement excuted in Laravel

To view the latest sql query executed in Laravel you can

DB::enableQueryLog();

print_r(DB::getQueryLog());

Note that you have to enable the query log before executing the query and view/print it after execution ..

A good practice is to enable it only in Local environment

if (App::environment('local')) {
    // The environment is local
    DB::enableQueryLog();
}

 

How to sanitize raw data in Laravel

When doing a raw data query from user input like this:

$someVariable = Input::get("some_variable");

$results = DB::select( DB::raw("SELECT * FROM some_table WHERE some_col = '$someVariable'") );

we are at risk of SQL injection , to avoid that we can bin parameters to our query like this:

$someVariable = Input::get("some_variable");

$results = DB::select( DB::raw("SELECT * FROM some_table WHERE some_col = :somevariable"), array(
   'somevariable' => $someVariable,
 ));

 

Another point is that if we want to do a raw that doesn’t return a value, we can do it like this

DB::statement( 'ALTER TABLE HS_Request AUTO_INCREMENT=1111' );

and that way can take parameters as well

DB::statement( 'ALTER TABLE HS_Request AUTO_INCREMENT=:incrementStart', array('incrementStart' => 1111) );