Category Archives: Laravel

Installing composer on KeyHelp control panel

I’ve been trying to figure this out for the last 2 hours. But I have finally managed to install it.

From offical composer page copy paste first two lines

https://getcomposer.org/download/

like:

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'c31c1e292ad7be5f49291169c0ac8f683499edddcfd4e42232982d0fd193004208a58ff6f353fde0012d35fdd72bc394') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"

Then, since KeyHelp makes users folders as root you will need to use i.e. files folder for installing Composer with command above. Then use this command:

COMPOSER_HOME=/home/users/someuser/files/ php composer-setup.php

What this command does?! COMPOSER_HOME is var and enables you to write composer.phar inside different home path.

All this without root. That was the point in the first place. Root and composer are not good option.

Problem was with the permissions in the first place. Users are from root. And Composer wanted to use $cd to access home folder. It poined to /home/users/someuser (someuser is current logged in user).

Error: Unable to create Composer home directory “/home/users/someuser/.config/composer”: mkdir(): Permission denied

BitBucket laravel initial commit

I have found it here but since I have older phpstorm there is a way to do it easier

https://stackoverflow.com/questions/47613209/how-to-set-up-bitbucket-in-phpstorm-2019

Step 1: Install Bitbucket Linky using this guide. Note Bitbucket Connector is no longer being developed.
Step 2: Set up a new private repository on Bitbucket. If you’re using WordPress, I’d recommend creating a repository for each plugin you are developing, rather than for the entire install. Leave it empty for now.
Step 3 Create a new project in PHPStorm or use an existing one. Click VCS>Create Git Repository. Select the path of your project.
Step 4 Now the repository is properly set up, I then added – using Finder – all of my files into the local repository folder.
Step 5 Select all of your project – which should be in red text – and click VCS>Git>Add. This will have added these files to the project, but not yet pushed them to the remote server.
Step 6 Now select the root directory of your project and click VCS>Git>Commit Directory.
Step 7 Go to VCS>Git>Remotes and add a new remote. You need to get this in Bitbucket by clicking ‘I will be starting from scratch’ and then copying the URL (https://youraccount@bitbucket.org/youraccount/yourrepo.git) and pasting it into PHPStorm.
Step 8 Click VCS>Git>Push. This actually moves the files to the server.
Hope that helps some one – took me ages to figure out. You’re now in the capable hands of many guides on how to use Git.

After step 6 I couldn’t find Remotes so I just clicked on project folder, right click, git->repository->push and then clicked on top remote and then added bitbucket link (https) and all the files were being pushed there.

That’s it.

Laravel paths explained

For the reference because I tend to forget things sometimes.

// project's root folder    
echo base_path();

// 'app' folder    
echo app_path();        

// 'public' folder but inside app folder and not /home/admin/web/domain.com/public_html
echo public_path();

// 'storage' folder    
echo storage_path();

// 'storage/app' folder    
echo storage_path('app');

Laravel storage symbolic link

When you need to use storage use this:

ln -s /home/admin/domains/domain.com/app/storage/app/public/svetvesti_img /home/admin/domains/domain.com/public_html/svetvesti_img

ln -s is symbolic link source destination.

If you want to update symbolic link after, for example changing server (dedi or vps) then use this:

Creation -> ln -s {/path/to/file-name} {link-name}
Update -> ln -sfn {/path/to/file-name} {link-name}

Request in Laravel

Nice stuff, very helpfull.

https://laraveldaily.com/how-to-check-current-url-or-route/

Read whole post and then follow the link in comments to another theme to search for the solution to even bigger problem.