How to install Image Magick on Windows

Download the fitting Imagick-Packet from this source: Install the ImageMagick PHP extension in Windows | mlocati – Michele Locati

Be sure to select the fitting Verson Thread Safe or Not.

Unzip the Package.

Copy php_imagick.dll into your php-root/ext-Directory. Copy all the other DLL-Files directly to your /php-root directory.

Add extension=imagick to your php.ini file. Restart your WebServer or your comand shell. Enter php -v in your command shell and check that there are no errors.

curl does not work on laravel with php 8

first be sure you have activated the curl-extension in your php.ini file.

After that get the cacert.pem file from curl – Extract CA Certs from Mozilla and safe it o your computer. i saved it into my php-directory. after that edit php.ini again and modify the following entry to point to the .pem.file:

[curl]
; A default value for the CURLOPT_CAINFO option. This is required to be an
; absolute path.
curl.cainfo = "C:\php\php80\cacert.pem"

Install Bootstrap in Laravel 8

run those commands in your project:

npm install bootstrap
npm install sass
npm install sass-loader

If not exists, create the file

resources/sass/app.scss

and add this:

@import '~bootstrap';

and last add the compilation in the file webpack.mix.js:

mix.sass('resources/sass/app.scss', 'public/css')

After that compile it with npm run dev and you’ll see public/css/app.css

After that you can add this code to your template to import bootstrap:


<link href="{{ asset('css/app.css') }}" rel="stylesheet">

iGITt iGITt – Initiales

Git global setup
git config --global user.name "User Name"
git config --global user.email "user@example.com"
Create a new repository in Git
git clone https://gitlab.abc.de/username/project.git
cd bmln
git switch -c main
touch README.md
git add README.md
git commit -m "add README"
git push -u origin main
Push an existing folder
cd existing_folder
git init --initial-branch=main
git remote add origin https://gitlab.abc.de/username/project.git
git add .
git commit -m "Initial commit"
git push -u origin main
Push an existing Git repository
cd existing_repo
git remote rename origin old-origin
git remote add origin https://gitlab.abc.de/username/project.git
git push -u origin --all
git push -u origin --tags

How to install PHP 7.3 on Windows 10

First of all download the PHP-Version you want to install. In my case it will be the PHP 7.3 x64 Thread Save versio. This is the link to the download section on php.net: https://windows.php.net/download#php-7.3 In my case i downloaded the ZIP-file of VC15 x64 Thread Safe (2020-Oct-27 16:52:12). Unzip the ZIP archive to a new folde which will be your php installation folder. So choose wisely 🙂 I used c:\php\php73 for that. After you have unzipped the PHP-Archive you need to locate the file php.ini-development and rename it to php.ini.

Open the php.ini file in any texteditor and change the extension_dir settings to the choosen directory, followed by an /ext. In my case its c:\php\php73\ext. Or you can set it like below:

; On windows:
extension_dir = "ext"

After that you need to add your path to the php-directory (in my case: C:\php\php73) to the Windows PATH variable. Search for “PATH” in the Windows Search-Bar to edit the environment variables.

Edit Environment Variables

Search in the system variable for the Path entry and edit this to add your PHP-path

After you have added your line click ok on all Windows to save your settings

To verify everything worked correctly open your command shell by typing cmd into the windows search bar

and type php -v in your command shell. You shall get the version information of your php installation. And now everything is done.

The same procedure is for every other php version like 7.x or 7.4. To install php in different directories (in my case C:\php\phpVERSION) gives you the chance to use different php version on Command Line Interface by setting the direct pth to the executable CLI.

Compare two tables to get all unlinked entries

I have the problem on RolandRadio, that a lot of people try to modify the charts and register to vote. All users not verified by Mail are deleted after 24 hours to avoid fake users but some of them already mass-voted on titles.

So i needed to find out if there are ratings by users already non existent in the users table. I came up with this mySQL-Solution:

select * 
from ratings A
Where Not exists (select 1 from users B Where A.model_id = B.id)

Or without the aliasing:

select * 
from ratings
WHERE NOT exists (select 1 from users Where ratings.model_id = users.id)

So i select all from the table ratings and get all those entries where the model_id-column of the ratings-table is not in the id of the users-table.

This brought up 1600 ratings of already deleted users. i hate it that people are so manipulative on the charts. Now i need to do a cron-tab-command to delete ratings of deleted users every day. Also i included

     if (Auth::user()->verified != 1) {
            session()->flash('message', 'You must verify your email first!');
        } 

into the rating function to avoid users not verified to rate on titles.

1071 Specified key was too long;

If you use an older Version of mySQL or MariaDB Laravel throws an error on the first migration on your database. Thats cause the defaultStringLentth needs to be set to a maximum length of 191 characters.

    public function boot()
{
Schema::defaultStringLength(191);
}
}

Add this to your AppServiceProvider.php File and rerun your migration

Dont forget to add

use Illuminate\Support\Facades\Schema;

Adding a command to laravel deleting all unwanted users :-)

As spammer start flooding my users table with fake-accounts i startet to develop a command for laravel to run in a cron job for deleting all users which didnt verified their email within the last 24 hours.

A nice how-to do a laravel console command for cron can be found at: https://tutsforweb.com/how-to-set-up-task-scheduling-cron-job-in-laravel/

This is my routine to select all users which haven’t confirmed their email and their register date is older than 24 hours.

    public function handle()
    {
         $results = User::whereNull('email_verified_at')->get();
        $results = $results
            ->where('created_at', '<', Carbon::now()->subDays(1)->toDateTimeString());

        foreach ($results as $result)
        {
            $result->delete();
        }

    }

Added the following command to the crontab by crontab -e on the webserver to execute the command:

cd /var/www/vhosts/rolandradio.net/rolandradio2020 && /opt/plesk/php/7.4/bin/php artisan schedule:run >> /dev/null 2>&1

Set Laravel-Project to “down” during updates

Everytime i start an update of the whole project it takes hours to upload all the new updated files to my web server.

To avoid a massive downtime for the user without informing them about the status and displaying any errors i just touch a file within the project:

project->storage->framework

there i add a file called “down” and the site goes into “down-mode” – atfer i finished my work i rename the file to “down-” to bring up the site agein. I configured the Error 503 page to display a nicer version of the error.