Monday, 7 February 2022

Makefile miscellaneous commands

Some miscellaneous commands for makefile This command will cd to a page and run command inside the page, if successful succeeding commands will be called.


build:adminx	font	js

js:
	npm run build

font:
	npm run gulp iconfont

adminx:
	cd admin; npm run build
    
    
Share:

Monday, 31 January 2022

Thursday, 27 January 2022

PHP Google GeoCoding Getting Latitude & Longitude

  
private function getGeoLocation($address)  
   {  
     try {  
       $url = 'https://maps.google.com/maps/api/geocode/json';  
       $address = str_replace(["'", '"'], " ", $address);  
       $address = str_replace([" ", " "], "+", $address);  
       $query_array = array(  
         'address' => $address,  
         'key' => env('GOOGLE_MAP_API_KEY')  
       );  
       $query = http_build_query($query_array);  
       $content = file_get_contents($url . '?' . $query);  
       $output = json_decode($content);  
       $result = [];  
       if ($output->status == "OK") {  
         $result['latitude'] = $output->results[0]->geometry->location->lat;  
         $result['longitude'] = $output->results[0]->geometry->location->lng;  
       }  
       return $result;  
     } catch (\Exception $ex) {  
       return [];  
     }  
   }  
Share:

Saturday, 13 March 2021

Creating 2 folder location on Vagrant homestead.yaml



---

ip: "192.168.10.10"

memory: 2048

cpus: 2

provider: virtualbox

authorize: ~/.ssh/id_rsa.pub

keys:

    - ~/.ssh/id_rsa

folders:

    - map: /Users/junedc/Desktop/AMyProject/
      to: /home/vagrant/code1/


    - map: /Users/junedc/Desktop/AMyProject2/
      to: /home/vagrant/code2/

sites:

    - map: laracartvue.test
      to: /home/vagrant/code1/laracart-vue/public

    - map: backend.test
      to: /home/vagrant/code2/backend_template/public

    - map: laravel8.test
      to: /home/vagrant/code2/laravel8/public

ssl:

    - true

databases:
    - homestead

features:
    - mariadb: false
    - ohmyzsh: false
    - webdriver: false


Share:

Monday, 19 October 2020

Creating a Secured Laravel Homestead SSH

Open Homestead.yaml file and add SSL = true it will create crt file in /etc/nginx/ssl


Sample Homestead.yaml file
ip: "192.168.10.10"
memory: 2048
cpus: 2
provider: virtualbox

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

folders:

    - map: /Users/junedc/Desktop/AMyProject/

      to: /home/vagrant/code1/


    - map: /Users/junedc/Desktop/AMyProject2/

      to: /home/vagrant/code2/


sites:

    - map: backend.test

      to: /home/vagrant/code1/backend_template/public


    - map: laravel8.test

      to: /home/vagrant/code2/laravel8/public


ssl:
     - true

Some commands to generate ssh key,  create a certificate, reload the new settings

xxxx
 ssh-keygen -t rsa
 vagrant up 
 vagrant ssh 
 cp cafefrends.test.crt /home/vagrant/code/cafefrends 
 
 vagrant halt
 vagrant reload --provision


In your mac KeyChain Access Add the crt file that was created in the previous step and set the SSL to 'Always Trust'
Share:

Thursday, 31 October 2019

Laravel creating an interface and implementation dynamically

Somehow you need to run a different implementation depending on system environment This is what i have done for one of my case
In your .env file

DOCUMENT_INTERFACE=GoogleCloud
#DOCUMENT_INTERFACE=LocalStorage
In my AppServiceProvider.php


   use Illuminate\Support\Facades\App;
   public function register()
    {
        $this->app->bind(DocumentInterface::class, function () {
            $className = 'Path\To\Interfaces' . '\\' . env('DOCUMENT_INTERFACE') . 'Implementation';
            $class = App::make($className);
            return new $class();
        });
    }
       
DocumentInterface.php

interface DocumentInterface
{
    public function create(DocumentUpload $documentUpload);
}

GoogleCloudImplementation.php


class GoogleCloudImplementation implements DocumentInterface
{
    public function create(DocumentUpload $documentUpload)
    {
       
    }
}

LocalStorageImplementation.php


class LocalStorageImplementation implements DocumentInterface
{
    public function create(DocumentUpload $documentUpload)
    {
       
    }
}

Share:

Popular Posts

Recent Posts

Pages

Powered by Blogger.

About Me

My photo
For the past 10 years, I've been playing with codes using PHP, Java, Rails. I do this for a living and love new things to learn and the challenges that comes with it. Besides programming I love spending time with friends and family and can often be found together catching the latest movie or planning a trip to someplace I've never been before.