Skip to content

Instantly share code, notes, and snippets.

View k1-end's full-sized avatar
💭
Learning

Keyvan k1-end

💭
Learning
View GitHub Profile
@irazasyed
irazasyed / downloadFileChunks.php
Last active May 3, 2024 09:57
PHP: File downloader function - Downloading files in chunks.
<?php
/**
* Download helper to download files in chunks and save it.
*
* @author Syed I.R <syed@lukonet.com>
* @link https://github.com/irazasyed
*
* @param string $srcName Source Path/URL to the file you want to download
* @param string $dstName Destination Path to save your file
* @param integer $chunkSize (Optional) How many bytes to download per chunk (In MB). Defaults to 1 MB.
@infostreams
infostreams / UserFromBearerToken.php
Last active January 2, 2024 05:47
How to retrieve or authorize a User object from a Laravel Bearer API token
<?php
use \League\OAuth2\Server\ResourceServer;
use \Laravel\Passport\TokenRepository;
use \Laravel\Passport\Guards\TokenGuard;
use \Laravel\Passport\ClientRepository;
use \Illuminate\Support\Facades\Auth;
use \Illuminate\Http\Request;
function getUser($bearerToken) {
$tokenguard = new TokenGuard(