working on it ...

Filters

Explore Public Snippets

Sort by

Found 15 snippets matching: cloudways

    public by azazqadir modified Dec 15, 2017  455  1  5  -1

    Installing PHP Website on Linode Server

    Here is how you can easily host a PHP based website easily and quickly on Linode using Cloudways PaaS: https://www.cloudways.com/blog/host-php-on-linode/
    <?php
    echo rand() . "\n";
    echo rand() . "\n";
    
    echo rand(5, 15);
    ?>

    public by azazqadir modified Nov 15, 2017  358  0  3  0

    Using Eloquent Outside of Laravel for Other PHP Apps. Source: https://www.cloudways.com/blog/eloquent-illuminate-in-php-without-laravel/

    Using Eloquent Outside of Laravel for Other PHP Apps. Source: https://www.cloudways.com/blog/eloquent-illuminate-in-php-without-laravel/: bootstrap.php
    <?php
    
    
    
    require "vendor/autoload.php";
    
    use Illuminate\Database\Capsule\Manager as Capsule;
    
    
    
    $capsule = new Capsule;
    
    
    
    $capsule->addConnection([
    
       "driver" => "mysql",
    
       "host" =>"127.0.0.1",
    
       "database" => "acl",
    
       "username" => "root",
    
       "password" => ""
    
    ]);
    
    $capsule->setAsGlobal();
    
    $capsule->bootEloquent();
    
    

    public by azazqadir modified Aug 18, 2017  244  1  3  0

    Controller for File Upload in CodeIgniter. Full tutorial here: https://www.cloudways.com/blog/codeigniter-upload-file-image/

    Controller for File Upload in CodeIgniter. Full tutorial here: https://www.cloudways.com/blog/codeigniter-upload-file-image/: upload_controller.php
    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
    class Upload_Controller extends CI_Controller {
    public function __construct() {
    parent::__construct();
    }
    public function custom_view(){
    $this->load->view('custom_view', array('error' => ' ' ));
    }
    public function do_upload(){
    $config = array(
    'upload_path' => "./uploads/",
    'allowed_types' => "gif|jpg|png|jpeg|pdf",
    'overwrite' => TRUE,
    'max_size' => "2048000", // Can be set to particular file size , here it is 2 MB(2048 Kb)
    'max_height' => "768",
    'max_width' => "1024"
    );
    $this->load->library('upload', $config);
    if($this->upload->do_upload())
    {
    $data = array('upload_data' => $this->upload->data());
    $this->load->view('upload_success',$data);
    }
    else
    {
    $error = array('error' => $this->upload->display_errors());
    $this->load->view('custom_view', $error);
    }
    }
    }
    ?>
    
    

    public by azazqadir modified Oct 9, 2017  313  0  3  0

    Laravel REST API Authentication with Passport: https://www.cloudways.com/blog/rest-api-laravel-passport-authentication/

    Laravel REST API Authentication with Passport: https://www.cloudways.com/blog/rest-api-laravel-passport-authentication/: auth.php
    'guards' => [
    
       'web' => [
    
           'driver' => 'session',
    
           'provider' => 'users',
    
       ],
    
    
    
       'api' => [
    
           'driver' => 'passport',
    
           'provider' => 'users',
    
       ],
    
    ],
    
    

    public by azazqadir modified Sep 27, 2017  235  0  3  0

    Laravel Browser Testing: https://www.cloudways.com/blog/laravel-dusk-testing-todo-app/

    Laravel Browser Testing: https://www.cloudways.com/blog/laravel-dusk-testing-todo-app/: AppServiceProvider.php
    use Laravel\Dusk\DuskServiceProvider;
    
    public function register()
    {
        if ($this->app->environment('local', 'testing')) {
            $this->app->register(DuskServiceProvider::class);
        }
    }
    
    

    public by azazqadir modified Oct 16, 2017  156  0  2  0

    Laravel Blade Layout. Learn how you can quickly create a layout in Laravel using the Blade: https://www.cloudways.com/blog/create-laravel-blade-layout/

    Laravel Blade Layout. Learn how you can quickly create a layout in Laravel using the Blade: https://www.cloudways.com/blog/create-laravel-blade-layout/: head.blade.php
    <meta charset="utf-8">
    
    <meta name="description" content="">
    
    <meta name="Saquib" content="Blade">
    
    <title>Checkout our layout</title>
    
    <!-- load bootstrap from a cdn -->
    
    <link rel="stylesheet" href="//netdna.bootstrapcdn.com/twitter-bootstrap/3.0.3/css/bootstrap-combined.min.css">
    
    

    public by azazqadir modified Feb 20, 2018  699  1  4  1

    LEMP on Debian

    Learn how to install LEMP on Debian: https://www.cloudways.com/blog/how-to-create-a-lemp-stack-on-debian-server/
    php
    location ~ \.php$ {
    
                   
    
                   fastcgi_pass unix:/var/run/php5-fpm.sock;
    
                   fastcgi_index index.php;
    
                   fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    
                   include fastcgi_params;
    
                   
    
           }			

    public by azazqadir modified Nov 21, 2017  557  0  5  1

    CDN integration in Yii2 App

    How to integrate CloudwaysCDN with Yii2 applications: https://www.cloudways.com/blog/cdn-in-yii2/
    // ...
    
    'components' => [
    
       // ...
    
    'cdn' => [
                'class' => '\yii2cdn\Cdn',
                'baseUrl' => defined ('YII2CDN_OFFLINE')
                    ? 'http://localhost/yii2/cdn'
                    : '//71265-358070-raikfcquaxqncofqfm.stackpathdns.com/cdn',
                'basePath' => dirname(__DIR__, 2) . '/cdn',
                'components' => [
                    'font-awesome' => [
                        'css' => [
                            [
                                // local version
                                'font-awesome.min.css',
                                // cdn version
                                '@cdn' => '//71265-358070-raikfcquaxqncofqfm.stackpathdns.com/cdn/font-awesome/css/font-awesome.min.css',
                            ]
                        ]
                    ]
                ],
            ],
     // ...
    
    ],
    
    // ...

    public by azazqadir modified Apr 11, 2018  651  1  5  0

    Using WooCommerce Rest API for Custom Dashboard

    Using WooCommerce Rest API (https://www.cloudways.com/blog/custom-dashboard-using-woocommerce-php-rest-api/ ) to create a Custom Dashboard
    <div class="container">
    
                                      <h2 class="sub-header">Customers List</h2>
    
                                      <div class='table-responsive'>
    
                                          <table id='myTable' class='table table-striped table-bordered'>
    
                                              <thead>
    
                                                  <tr>
    
                                                      <th>Email</th>
    
                                                      <th>Name</th>
    
                                                      <th>Billing Address</th>
    
                                                      <th>Total Orders</th>
    
                                                      <th>Total spent</th>
    
                                                      <th>Avatar</th>
    
                                                      <th>Actions</th>
    
                                                  </tr>
    
                                              </thead>
    
                                              <tbody>
    
                                                  <?php
    
                      foreach($customers as $customer){
    
    
    
                      echo "<tr><td>" . $customer["email"]."</td>
    
                                <td>" . $customer["first_name"].$customer["last_name"]."</td>
    
                                <td>" . $customer["billing"]["address_1"]."</td>
    
                                <td>" . $customer["orders_count"]."</td>
    
                                <td>" . $customer["total_spent"]."</td>
    
                                <td><img height='50px' width='50px' src='".$customer["avatar_url"]."'></td>
    
                                 <td><a class='open-AddBookDialog btn btn-primary' data-target='#myModal' data-id=".$customer['id']." data-toggle='modal'>Update</a>
    
                                 <a class='open-deleteDialog btn btn-danger' data-target='#myModal1' data-id=".$customer['id']." data-toggle='modal'>Delete</a></td></tr>";
    
                      }
    
    
    
                      ?>
    
                                              </tbody>
    
                                          </table>
    
                                      </div>
    
      </div>												

    public by azazqadir modified Jan 18, 2018  457  1  5  0

    Adding Captcha in CodeIgniter

    Source: https://www.cloudways.com/blog/captcha-in-codeigniter/
    <?php
    
    defined('BASEPATH') OR exit('your exit message');
    
    class Captcha extends CI_Controller
    
    {
    
       function __construct()
    
       {
    
           parent::__construct();
    
           $this->load->helper('captcha');
    
       }
    
       public function index()
    
       {
    
           if ($this->input->post('submit')) {
    
               $captcha_insert = $this->input->post('captcha');
    
               $contain_sess_captcha = $this->session->userdata('valuecaptchaCode');
    
               if ($captcha_insert === $contain_sess_captcha) {
    
                   echo 'Success';
    
               } else {
    
                   echo 'Failure';
    
               }
    
           }
    
           $config = array(
    
               'img_url' => base_url() . 'image_for_captcha/',
    
               'img_path' => 'image_for_captcha/',
    
               'img_height' => 45,
    
               'word_length' => 5,
    
               'img_width' => '45',
    
               'font_size' => 10
    
           );
    
           $captcha = create_captcha($config);
    
           $this->session->unset_userdata('valuecaptchaCode');
    
           $this->session->set_userdata('valuecaptchaCode', $captcha['word']);
    
           $data['captchaImg'] = $captcha['image'];
    
           $this->load->view('captcha/index', $data);
    
       }
    
       public function refresh()
    
       {
    
           $config = array(
    
               'img_url' => base_url() . 'image_for_captcha/',
    
               'img_path' => 'image_for_captcha/',
    
               'img_height' => 45,
    
               'word_length' => 5,
    
               'img_width' => '45',
    
               'font_size' => 10
    
           );
    
           $captcha = create_captcha($config);
    
           $this->session->unset_userdata('valuecaptchaCode');
    
           $this->session->set_userdata('valuecaptchaCode', $captcha['word']);
    
           echo $captcha['image'];
    
       }
    
    }
    • Public Snippets
    • Channels Snippets