Laravel composer fork project for urgent own use

Nowadays, we definitely using other people packages in own project. What if you found a bug or special workflow to suit your own need. But the project owner didn’t accept the pull request or them didn’t maintenance the project anymore.

If you brave enough you can fork it and continue maintaining it. So people can continue with your repo.

However, I don’t think it is the common use case. So what should you do? Thank God, it has an easy fix in your composer.

First, you, of course, need to fork the project. Then create a branch name start with dev- ,e.g  dev-fix-something then do whatever you need then commit to your repo.

In you composer.json file. add the follow lines. Can be before require tag:

"repositories": [{
  "type": "vcs",
  "url": "https://github.com/my-name/awesomeproject"
}],

Then in the require tag, u need to change original package repo to your new branch.

"require": {
    "php": ">=7.0.0",
    "pro-developer/awesomeproject": "dev-fix-something",

Save your composer.json file. Then go to Terminal run composer update

Then you should be using your own fix branch. If the repo owner finally accepted your pull request, then you can switch back to the original require version.

Note:

If you somehow run the composer update got error like below:-

Your requirements could not be resolved to an installable set of packages.

Problem 1
The requested package pro-developer/awesomeproject dev-fix-something exists as pro-developer/awesomeproject[0.1, 0.1.1, 0.1.2, 0.1.3, 0.1.4, 0.1.5, 1.0, 1.0.1, 1.0.2, 1.0.3, 1.0.4, 1.0.4.1, 1.0.5, 2.0, 2.0.1, 2.0.10, 2.0.12, 2.0.2, 2.0.3, 2.0.4, 2.0.5, 2.0.6, 2.0.7, 2.0.8, 2.0.9, 3.0, 3.0.1, 3.0.10, 3.0.11, 3.0.12, 3.0.2, 3.0.3, 3.0.4, 3.0.5, 3.0.6, 3.0.7, 3.0.8, 3.0.9, 3.1, 3.1.1, 3.1.10, 3.1.11, 3.1.12, 3.1.2, 3.1.3, 3.1.4, 3.1.4.1, 3.1.6, 3.1.7, 3.1.8, 3.2.0, 3.2.1, 3.2.2, 3.3.0, 3.3.1, 3.3.2, 4.0, 4.0.1, 4.0.10, 4.0.11, 4.0.12, 4.0.2, 4.0.3, 4.0.4, 4.0.5, 4.0.6, 4.0.7, 4.0.8, 4.0.9, 4.1, 4.1.1, 4.1.10, 4.1.11, 4.1.12, 4.1.2, 4.1.23, 4.1.3, 4.1.4, 4.1.5, 4.1.6, 4.1.7, 4.1.8, 4.1.9, 5.0.0, dev-dev-fix-something] but these are rejected by your constraint.

You could be gotten wrong branch name. In the above example the correct name should be dev-dev-fix-something, just make the changes in your composer.json then you can ready to run composer update again. It should be working fine.

After the composer update, you can run composer show -v pro-developer/awesomeproject to see the details. You should be to see the support source is from your own repo.

That’s all. Thanks for reading. Happy Coding! Make more great open source project and contribute more to the community.

open edit from cmd like notepad++, sublime or atom

If you come from Mac or Linux. When you want to edit a program. You can easily use console editor to edit the file.

e.g vi /etc/hosts so you can edit the hosts file.

But how you able to do it in Windows. Previously, I need to go to the Windows Explorer, go to that path and then open notepad drag and drop (If you turn off User Account Control Settings – which is not recommended by Windows). Kind of many step to do…

The easy way to accomplished is using below command. I assumed you had installed notepad++

start notepad++ composer.json

In this way, you able to open the file directly from notepad++ or other editor you like.

Please be reminder you only can do so, if you editor had added into SYSTEM ENVIRONMENT PATH.

Tips: Another good cmd alternative in windows I am using https://conemu.github.io/

runcloud use two projects sharing the same media folder

If you have a chance using symlink in your project. E.g your media folder. You might be using a symlink to reference the same media directory.

When I deploy my project to live. I keep hitting `Cannot save image intervention image. NotWritableException in Image.php line 138`

I am sure I am using the same owner for both directories. However it kind of weird to having this error message.

Then I started to trace the path. I tested with andFile::isDirectory File::iswritable. Then I was having open_basedir restriction in effect. File(/) is not within the allowed path(s):

Then this made me proceed to next checking.Finally, I found out this OPEN_BASEDIR issue.

In runcloud they had provided OPEN_BASEDIR for security purpose.

So what you have to do is include your another project repo into. And they have warned you about the risk. Make sure you know what you are doing.

Laravel Valet with SubDomain

In order to allow to use Laravel Sub Domain Route in Your Laravel Valet.

Let’s say my project folder name is ‘forum’. I would like the forum users to have their own public profile page via sub-domain.

Here is my route file:-

Route::domain('{account}.forum.dev')->group(function () {
    Route::get('user/{id}', function ($account, $id) {
        //
    });
});

In my Valet Folder. I need to use a symlink to archive the goal. In my case, I use Ken as a test user. Unfortunately, you can’t archive it via wildcard in Valet.

ln -s forum ken.forum

That’s all. Happy Coding

PHP Round Up to nearest Array

//array list
$array = array(1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 150, 250, 300, 350, 400, 450, 500, 600, 700, 800, 900, 1000);

//array round up function
function getArrayRoundUp($array, $number) {

sort($array);
foreach ($array as $a) {
if ($a >= $number) return $a;
}
return end($array);
}

//assume this is the value
$value = 904.5;

$nearest = getArrayRoundUp($array, $value);

//the expect result will be 1000
echo $nearest;

 

Laravel Valet for OpenCart 2.x using Custom Valet Drivers

Using Laravel Valet with OpenCart 2.x?

I am taking a while to understand how the valet custom driver work for my own OpenCart project.

1. My OpenCart project is located at ~/Sites/myshop (myshop is my folder name, it is very important how you name your driver)
2. Go to ~/.valet/Drivers/
3. Create a file name MyshopValetDriver.php
4. Template you can reference here. Laravel Valet for OpenCart 2.x
5. Tata, your Opencart now support SEO URL with Laravel Valet.

 

Valet Version: v2.0.5
Opencart Version: v2.3.0.2 (It will works on any Opencart 2.x version)

 

Vagrant Docker Windows 10 cannot ping from Host

If you notice after you restart your computer. Then you run vagrant up, and you can’t access to the vagrant image from the Windows 10 Vagrant Virtualbox with Docker Setup tutorial.

ping 192.168.33.10 there are no response….

What you can do is follow the below step to reactivate again.

  1. SSH to the vagrant machine using 127.0.0.1:2222
  2. sudo ip addr del 192.168.33.10/24 dev enp0s8 remove the enp0s8
  3. sudo brctl addif docker1 enp0s8 bridge the network again
  4. Tata~ now you can ping from your host machine again
  5. Done. Continue your docker development.

Thank you for reading.

Laravel Valet enable xdebug with PHPStorm

Setting up Xdebug with Laravel Valet

 

Extra Note:

  1. Once you have upgraded new version of PHP, E.g PHP7.0 to PHP7.1. Remember install the xdebug package again.
  2. brew install php71-xdebug
  3. open file /usr/local/etc/php/7.1/conf.d/ext-xdebug.ini
  4. Added the following line after the zend_extension="/usr/local/opt/php71-xdebug/xdebug.so"
xdebug.remote_enable=true
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp

Last step run valet install to restart everything.

install and compile particular apache in ubuntu

Due to testing purpose, I need a specific Apache version. So I bring up a ubuntu docker and play around with it.

In my case, I need Apache 2.4.23 version.

Archive version you can access to https://archive.apache.org/dist/httpd/

Just in case, if your linux does not have wget, you can install via apt-get install wget

Follow the below script to compile your apache version

cd ~
wget https://archive.apache.org/dist/httpd/httpd-2.4.23.tar.gz
tar -zxf httpd-2.4.23.tar.gz

wget http://www-eu.apache.org/dist//apr/apr-1.6.2.tar.gz
wget http://www-eu.apache.org/dist//apr/apr-util-1.6.0.tar.gz
tar -zxf apr-1.6.2.tar.gz
tar -zxf apr-util-1.6.0.tar.gz

cd httpd-2.4.23/srclib/
cp ~/apr-1.6.2 ./apr
cp ~/apr-util-1.6.0 ./apr-util

apt-get install build-essential

apt-get install libpcre3 libpcre3-dev libexpat1-dev 

./configure

 

For install detail, you can read from here.

http://httpd.apache.org/docs/2.4/install.html

Once you have run the above command, you should able to make and make install

That’s all!

 

Runcloud.io Review

If you are looking painless server management. I would like to recommend RunCloud.io. The main reason, of course, it is Made in Malaysia!

First Class Interface

It has beautiful and easy to use User Interface.

Compatible Price

It only cost USD$10 per month. It is considered good price for the unlimited server!

Have a look now! RunCloud.io.