PHP

  • Symfony Security Authorization

    There are several way to make authorization on your site with Symfony. First is in your security.yml on the same level as firewalls tag: access_control: – { path: ^/admin, roles: ROLE_USER } This will block all users that don’t have ‘ROLE_USER’ to admin page. Second option is to use Controller. Inside Method insert: if(!$this->get(‘security.authorization_checker’)->isGranted(‘ROLE_ADMIN’)){…

  • PHP CURL Function Example

    This function is populated with all needed data for curl to be executed function get_curl($site_url){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $site_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, “GET”); curl_setopt($ch, CURLOPT_ENCODING, ‘gzip, deflate’); $headers = array(); $headers[] = “Accept-Encoding: gzip, deflate, sdch”; $headers[] = “Accept-Language: en-US,en;q=0.8”; $headers[] = “Upgrade-Insecure-Requests: 1”; $headers[] = “User-Agent: Mozilla/5.0 (X11; Linux…

  • CodeIgniter – custom 404 error page

    application/config/routes.php $route[‘404_override’] = ‘my404’; application/controllers/My404.php

  • CodeIgniter Session Error – Operation not Permitted

    On some hostings you can receive this error. A PHP Error was encountered Severity: Warning Message: unlink(/tmp/ci_session0189a7f1c86eb18fb70afcfedc2d5040e9c23146): Operation not permitted Filename: drivers/Session_files_driver.php To fix this go to application > config > config.php and edit this line: $config[‘sess_save_path’] = BASEPATH . ‘cache/’;

  • Laravel first steps

    Hello, this article is for beginners and will show basic functions. Installation of Laravel To begin with instalation we need composer. In console write the following. composer create-project –prefer-dist laravel/laravel NameOfTheProject What is artisan Artisan is the name of the command-line interface included with Laravel. It provides a number of helpful commands for your…

  • Laravel on shared hosting

    I will show you not the fastest but easiest way to move Laravel project to shared hosting. You need to be sure that you are using PHP version >= 5.6.4. First step First connect to your FTP and create folder outside “public_html”. You can use any name but in this example I will use…

  • Cron Job for Codeigniter

    In my practice there are two simple solutions. First: 0 0 1 * * php /home/USER/public_html/index.php NAME-OF-CONTROLLER NAME-OF-METHOD example -> php /home/User/public_html/index.php TestCron index Second: 0 0 1 * * curl –silent URL-OF-THE-SCRIPT example -> curl –silent http://maratonkata.nikolaynikolov.net/TestCron

  • Codeigniter 3 – Fast setup

    Download and extract codeigniter. In main folder create another folder named assets. There will be additional files for css, js and more. Setup configuration files. Go to application/config: – in autoload.php $autoload[‘libraries’] = array(‘database’,’session’); $autoload[‘helper’] = array(‘url’,’form’); – in config.php $config[‘base_url’] = ‘http://www.example.com/’; $config[‘index_page’] = ”; $config[‘encryption_key’] = ‘someEncryptionKey’; $config[‘sess_save_path’] = sys_get_temp_dir(); //Fix problems…

  • Multilanguage CodeIgniter 3.0

    In this tutorial we will implement multilanguage to CodeIgniter. Site Default Language Open the application/config/config.php file and specify the site’s default language. $config[‘language’] = ‘bulgarian’; //Language you want to be default Language Files The language files must be named with _lang suffix. For example, if you want to create a file containing site’s message…