fabiochiu/medium-articles huggingface dataset:
Desarrollando con Apple Silicon
By: Gabriel G. Casuso
Tags: Apple Silicon, Docker, M1, PHP, Development

Learn more. Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Make Medium yours. Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore
Analyse Symfony code quality using Sonarqube
By: Lionel Owono
Tags: Symfony, Sonarqube, Docker, PHP, Programming

Using Sonarqube

In this tutorial, we’ll use Sonarqube Community Edition but we won’t download it on the website, we’ll use his docker’s image.

To run the command lines below, you should have docker installed.

Open the terminal

Run commands below on that terminal (maybe on Linux you should run all that command as a sudoer)

Open your browser

Launch: http://localhost:9000

Symfony app code analysis

To analyse your Symfony application, you should :

Create a project on Sonarqube configure your application to be analyzed by Sonarqube Launch the analysis on your Sonarqube container

Create a Sonarqube project

Launch http://localhost:9000 in the browser

Below some snapshots of steps to follow when you create a project :

In the final step, you have the command line to launch your analysis, but since our Sonarqube is running in a docker’s container our command will be a little bit different :)

Add a Sonarqube config file in the root directory of your project (sonar-project.properties):

Launch the command in the terminal

Command-line structure :

docker run -ti -v [project_absolute_path]:[project_absolute_path_inside_container] — link sonarqube newtmitch/sonar-scanner -Dsonar.projectKey=[projectKey] -Dsonar.sources=[directories_containning_sources_code] -Dsonar.login=[login_provided_in_the_final_step] -Dsonar.projectBaseDir=[project_absolute_path_inside_container]

Example (using configurations below) :

docker run -ti -v /home/lionel/projects/trade_cube/:/root/trade_cube — link sonarqube newtmitch/sonar-scanner -Dsonar.projectKey=MediumProjectKey -Dsonar.sources=src -Dsonar.login=ab58b9bc33ba27cdf69ddb359795baffa1657d0a -Dsonar.projectBaseDir=/root/trade_cube

Result:

Command-line

Sonarqube report

Conclusion

It is important to always analyze your code, because :

Your application will be more robust

Your application will be maintainable

You’ll use to follow that best practice

It will give you good reflex when writing your code later

But notice that it will never give you a complete analysis, sometimes only a developer helps you.

I hope this little tutorial helped you, of course, it is not complete and I’m open to comments and ideas on how to make it better, thanks ;).

Sources;

👋 Join FAUN today and receive similar stories each week in your inbox! ️ Get your weekly dose of the must-read tech stories, news, and tutorials.

Follow us on Twitter 🐦 and Facebook 👥 and Instagram 📷 and join our Facebook and Linkedin Groups 💬
Iniciando um Servidor Web via PHP
By: Marcos Henrique
Tags: 100security, PHP, Servidor Web

Learn more. Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Make Medium yours. Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore
Building a Shopping Cart with Symfony 5
By: Quentin Ferrer
Tags: PHP, Symfony, Tutorial, Beginner

For the first time, I wrote a tutorial to learn the popular Symfony Framework by creating a simple shopping cart from scratch. I’ve been developing with Symfony for more than 8 years and I think it’s time for me to share my experience with you through this series of articles.

The tutorial describes the creation of a shopping cart with Symfony 5 step by step:

Hope you enjoy the ride. I tried to respect the best practices and use the base concepts of Symfony to allow you to reuse code and create your projects independently.

Happy Holidays 🎄
How to Host PHP on Amazon AWS EC2
By: Shahzeb Ahmed
Tags: AWS, Cloud Hosting, Php Development, Aws Ec2, PHP

If you want to deploy a PHP Web application on Amazon AWS EC2, One thing you should know, deploying the application on AWS is a complicated, long and headache process. You will have to go through tons of their documentation to understand how their system works. To make this process easier, I’d recommend using a managed hosting to deploy the application on Amazon AWS EC2.

Not every PAAS provider can deliver exceptional performance for PHP based applications. Amazon Web Service is the most popular choice among the most experienced PHP developers for deploying their PHP-based web applications.

It is interesting to note that having a managed host provider not only takes away your web hosting hassles but also enables you to focus on building awesome websites.

One of my favourite managed hosting out there is Cloudways. I’m going to show you how easy it is to deploy a PHP app through the Cloudways Platform, on Amazon AWS EC2. The platform takes away the complications of setting up apps through a command-line interface.

Let’s begin:

To host Amazon with a PHP app, the first step is to sign up for a Cloudways Account.

Step 1: Launch Server

To add a server, first, click on the ‘Add Server’ button on the top right corner.

Step 2: Select AWS EC2

Now, launch your desired application on your preferred cloud server. You can choose from AWS, Digital Ocean, Linode, and Vultr. For this tutorial, select AWS.

Step 3: Select Server Size, Bandwidth, Storage:

Now, it’s time to scale and select the resources, Use the sliders to set up Server Size, Bandwidth and Storage for your server.

Bandwidth

Database

Step 4: Select Server Location

Once you have setup the server, select the region in which you wish to host the server in and finally, Then, click on the ‘Launch Server’ button to begin installing PHP on AWS EC2 server.
PHP — RSS to JSON
By: Bayu Nugroho
Tags: Php Developers, Php7, Phpunit, Php Development, PHP

Someone who is obsessed with perfection,My interests range from technology to design. I am also interested in music,entrepreneurship, and others
Laravel Scenarios
By: Solum Designum
Tags: Laravel, Solumdesiginum, PHP, Package, Development

SolumDeSignum/scenarios

Solum DeSignum Scenarios is agnostic backend validation Scenarios package. To get started, install Scenarios using the…
How To Check RAM And CPU Usage In Laravel
Tags: Ubuntu, Laravel, Cpu, PHP, Ram

How To Check RAM And CPU Usage In Laravel Websolutionstuff ·Dec 22, 2020

Hello All,

In this small tutorial i will show you How To Check RAM And CPU usage In Laravel in Ubuntu OS. many time we require to check how much RAM and CPU usage of consumption in server if we have not code then we need to check manually every time , so here i will give you example with code So you can get data of RAM and CPU usage in your admin panel.
Schedule SMS with PHP and cron. This quick guide will demonstrate how…
Tags: Automation, PHP, Sms Api, Cron, Sms

This quick guide will demonstrate how to create a simple PHP script to automate weekly SMS send-outs.

What you will accomplish…

Every Saturday at 8 am an SMS is automatically sent to all gym members with a link to a schedule of the coming week’s class schedule.

What you need to follow this guide…

A 46elks account.

Ability to SSH into a Linux server.

Let’s get started🚀

Create a PHP file that sends SMS

This PHP file sends a preset message to a defined list of recipients. In your code editor, create a PHP file and copy the code so it looks like the example below, except with your 46elks authorization details where indicated by comments.

Parts of a cron command

It is good to have an overview of cron before we dive into our example. Below is a brief overview of cron commands and how they work. Here is a simple cron job example:

10 * * * * /usr/bin/php /www/virtual/username/cron.php > /dev/null 2>&1

There are two main components of a cron job:

First, the timing: 10 * * * * - here you set the minutes, hours, days, months, and weekday settings (more below).

Second, the command itself:

/usr/bin/php /www/virtual/username/cron.php > /dev/null 2>&1

The command itself in this example has three parts:

/usr/bin/php - PHP scripts are usually are executable by themselves which is why we need to run it through the PHP parser. You can use the command which php to check the correct path.

/www/virtual/username/cron.php - This is just the path to the script.

> /dev/null 2>&1 - (optional) This part is handling the output of the script.

In the above example, the cron job is set to send every 10 minutes — or more specifically, every 10th minute of every hour of every day of every month, every day of the week. An asterisk is a wildcard that stands for “all”.

Here is a break down of the timing elements:

Timing of a cronjob

Setting up our cronjob

Below is all the information you need to create a cron job that runs every Saturday at 8 am. Once you have access to your server, you can check if any current jobs are running with the following command to list all crontabs:

crontab -l

This will list the crontab contents.

(NOTE: There may be none.)

Now, we’ll edit the crontab:

crontab -e

At this point, assuming you’ve never changed the default editor for your server, you may find yourself in the vim editor. It can be a little confusing and scary the first time you use it, so here’s what to do:

Press ESC. Type “i” (for “insert”) to begin editing the file. Paste the cron command into the file. Press ESC Type “:wq” (for “write and quit”) to save and exit.

That’s it! 🥳 Now you can sit back and your gym members will be happy to receive their updates.

Some other potential use-cases for cron jobs
Do-You-Mean Laravel Search
Tags: String Similarity, Laravel, PHP, Search, Fuzzy Logic

We will use Jaro-Winkler Similarity to match the query value against the data in the table both Products and Application_Doc.

We don’t have to write an implementation for Jaro-Winkler Similarity there exists an amazing Laravel package we just need to add it via composer to our project.

composer require atomescrochus/laravel-string-similarities

The above code will filter based on the Jaro-Winkler Similarity and sort the collection based on similarity with the query against each column in the Product table and suggest a new collection.

The same for the ApplicationDoc table.

The above method will sort suggestions from each table based on the highest similarity.

The above method collects the suggestion and creates a new single dimension array.

We can paginate the result with this method

Add combine all the above in a single controller
Generating excel file using PHP
By: Suresh Kamrushi
Tags: PHP

Here i am sharing how one can generate Excel file using PHP library “PhpSpreadsheet”. To use library you need to install using composer. Open command window and excecute below command in your project folder:

composer require phpoffice/phpspreadsheet

It will create a new folder as “vendor” in your project and copy all files and folders as below:

Next create a file as “sample.php” and copy below code:

<?php

require 'vendor/autoload.php';

use PhpOffice\PhpSpreadsheet\Spreadsheet;

use PhpOffice\PhpSpreadsheet\Writer\Xlsx;

$spreadsheet = new Spreadsheet();

$sheet = $spreadsheet->getActiveSheet();

$sheet->setCellValue('A1', 'Hello World !');



$writer = new Xlsx($spreadsheet);

$writer->save('hello world.xlsx');

Now open your browser and open the file “sample.php” it will create a excel file as “hello world.xlsx” in same folder.

Originally published at http://sforsuresh.in.
PHP imagecolorallocate() & imagettftext() always generating black text
By: Indunil Ramadasa
Tags: Imagettftext, PHP, Imagecolorallocate, Imagecolorclosest

Today I encountered an issue with using PHP function imagettftext() for generating an image with some text. I was using the usual imagecolorallocate() function for generating color identifier.

$txt_font_color = imagecolorallocate($image3, $component_config['font_color']['r'], $component_config['font_color']['g'], $component_config['font_color']['b']);

imagettftext( $image3, $txt_font_size, $angel, $x, $y, $txt_font_color, $txt_font, $line );

Surprisingly it was generating black-colored text despite the set pure white color. Then I tried with giving different color codes and always it was generating black.

Later after googling on the issue, I found out that it is somewhat common. I was using a PNG with 8-bit palette. Apparently it given text color rgb(255,255,255) had been not in the palette of source image. In such cases function imagecolorallocate() returns false as it fails to process it.

The solution :

I used imagecolorclosest() function instead imagecolorallocate(). It solved the problem.

$txt_font_color = imagecolorclosest($image3, $component_config['font_color']['r'], $component_config['font_color']['g'], $component_config['font_color']['b']);

I also read that imagecreatetruecolor() along with imagecolorallocate() is also a solution.

Obviously there would be other solutions for this issue including changing the source image :) .
can give you exact knowledge of particular fields either in web development ( PHP , HTML , CSS, my sql or database )
Tags: PHP, Tutor, Private Tutor, HTML

can give you exact knowledge of particular fields either in web development ( PHP , HTML , CSS, my sql or database ) edubird ·Dec 21, 2020

Nod days its hard to find a good teachers or mentors. best part is to find indutrial experts who

can give you exact knowledge of particular fields either in web development ( PHP , HTML , CSS, my sql or database ) or in sports (cricket, football , hockey etc..)even in music or dancing

so its better to visit edubird.com
Lauren Jauregui post-modern story; the culprit of society, ‘refused top business studies’…
By: Povilas Brilius
Tags: Kawasaki, Bmw, Suzuki Method, PHP, Lauren Jauregui

It’s not depression, though, it’s a set of reached college goals before drawing this sketched art — i.e. étude in fine arts terms; formulated concisely. Even though MAC was blocked during the process, and oryx.io was far more alluring statements set, it was solely college art.

SS AI not passed D-Day officials were welcome in France and lately Germany, though the real story is hidden behind the nominal stage. Americans, won the WW2, were eager to establish post-modern society and the source of it was Berlin, at that time former Germany capital.

In these terms one employee enterprise means several sentences —
Create a simple Widget for Wordpress site content
By: Gabriel Kwaye
Tags: Wordpress Plugins, Widget, WordPress, Wordpress Development, PHP

I’m going to show a simple to quickly setup a Wordpress widget from scratch

Sometimes developers want to customize some contents to display on wordpress content and they often check to find an existing plugin that can help solve the issue quickly. In case the one found does not fit your needs then what to do ?

In this post I’ll walk through a simple code to create and display a widget on a web page that displays the site logo and description.

First, we need a class in the functions.php file

class Widget_Footer_LogoDescription extends WP_Widget { /** * Sets up the widgets name etc */ public function __construct() { $widget_ops = array( ‘classname’ => ‘Widget_Footer_LogoDescription’, ‘description’ => ‘Logo and site description‘, ); parent::__construct( ‘Widget_Footer_LogoDescription’, ‘Pied de page logo et description’, $widget_ops ); } /** * Outputs the content of the widget * * @param array $args * @param array $instance */ public function widget( $args, $instance ) { $description = get_bloginfo(‘description’); $logo = get_theme_mod( ‘custom_logo’ ); $image = wp_get_attachment_image_src( $logo , ‘full’ ); $image_url = $image[0]; echo “<img src=’”. $image_url . “‘ sizes=’100px’ alt=’’ class=’logo-2'>”; echo “<p class=’paragraph-7'>” . $description . “</p>”; } /** * Outputs the options form on admin * * @param array $instance The widget options */ public function form( $instance ) { } /** * Processing widget options on save * * @param array $new_instance The new options * @param array $old_instance The previous options * * @return array */ public function update( $new_instance, $old_instance ) { } }

Now that the class function is ready then register for the Widget

function custom_widget_footer() { register_widget(‘Widget_Footer_LogoDescription’); } add_action(‘widgets_init’, ‘custom_widget_footer’);

The last operation is to call the widget where we want to display in the site

<?php the_widget(‘Widget_Footer_LogoDescription’); ?>

Note that we pass here the name of the class function
How To Check Occupied Disk Space In Laravel
Tags: Ubuntu, Occupied, Laravel, Di̇sk, PHP

In this example we will see how to check occupied disk space in laravel.

in laravel. Many time we need requirements to check occupied disk space of server in admin side and we are checking manually if disk space are fully occupied or not so in this tutorial i will explain you how to check occupied disk space in laravel so you can check directly in admin side without any manual action. Also you can use this code in Ubuntu as well.

this code in as well. PHP provide built-in function to check total space and free space of server , here we will use these functions and will get output.

and of , here we will use these functions and will get output. So, first you need to create Controller for logical part.

I have created one controller and created disk_total_demo() function like below.

public function disk_total_demo()

{

$disktotal = disk_total_space('/'); //DISK usage

$disktotalsize = $disktotal / 1073741824; $diskfree = disk_free_space('/');

$used = $disktotal - $diskfree; $diskusedize = $used / 1073741824;

$diskuse1 = round(100 - (($diskusedize / $disktotalsize) * 100));

$diskuse = round(100 - ($diskuse1)) . '%'; return view('details',compact('diskuse','disktotalsize','diskusedize'));

}

Then after put below code in your details.blade.php file.

<html>

<head>

<link href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" rel="stylesheet">

</head>

<body>

<div class="col-sm-6 col-md-3">

<h2 class="no-margin text-semibold">Occupied Disk Space</h2>

<div class="progress progress-micro mb-10">

<div class="progress-bar bg-indigo-400" style="width: {{$diskuse}}">

<span class="sr-only">{{$diskuse}}</span>

</div>

</div>

<span class="pull-right">{{round($diskusedize,2)}} GB /

{{round($disktotalsize,2)}} GB ({{$diskuse}})</span>

</div> </body>

</html>

And finally we will get output like below screenshot.
Putting together Wordpress, Unitd and https
By: Alex Povolotsky
Tags: PHP, Nginx, Unitd, WordPress

Recently, I’ve got a simple task of setting up an empty site to be filled. Wordpres… well, just a wordpress.

Easy as a cake, yes?

(skipping installing nginx, php, requires extensions, certbot. On your favorite system in takes 3–5 simple commands and some time to work it out)

Why unitd? Well, why not? I just like it more than php-fpm. Let’s assume we have to use it.

Official instructions looks simple, but it stops one step before finish. https.

I’ve installed, configured, made basic setup, added ssl certificate and garbled my site to the point I could not get anything usable from admin panel. I’ve got Mixed Content Error.

I won’t explain it in details, there are more articles on the subject than one can read in his life; the only thing that is of any use is that’s intolerable.

Ok, let’s do from scratch! (note to any sane IT personnel: writing from scratch should be your last resort, not the first) Woops. Nothing happened.

After some time, I’ve made a simple info.php (<?php phpinfo(); ?>) and tried it (don’t forget to remove after finishing the work! May reveal sensitive information) — to find out that request came from 127.0.0.1, by http. Well, at least I know whom to blame (myself, I should remember that unitd has currently no provision to set remote_ip to real remote_ip).

There is an is_ssl() function over there in ./wp-includes/load.php, hammering it down to return true gave me access to admin page; not good after all.

But (a) it’s ugly (b) it will be overwritten during the next upgrade (c) I’d better fix REMOTE_ADDRESS as well.

But now, understanding what to fix, I’ve easily found out

in nginx.conf

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_set_header X-Forwarded-Proto $scheme;

in wp-config.php

/* === https and remote_address === */

if ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) ) {

if ( 'https' == $_SERVER['HTTP_X_FORWARDED_PROTO'] ) {

$_SERVER['HTTPS'] = 'on';

}

}

if ( isset( $_SERVER['HTTP_X_REAL_IP'] ) ) {

$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_REAL_IP'];

}

/* === https and remote_address === */

Easy as a cake, yes?

Kinda.

When cleaning up, I’ve found out that is_ssl still hardcoded to return true. Removing hardcode… breaks everything. Setting `$_SERVER[‘HTTPS’] = ‘on’;` in wp-config.php… works, but that’s a hardcode. Putting the code into info.php… works.

As my last resort, I’ve tried to read wordpress source. Up to loading of wp-config, it was straightforward. So there were no hidden `unset()`s, just no way for them.

So it HAD to be in my configs.

Looking at my nginx.conf, I’ve found that index.php is not handled by *.php rule! It has it’s own!

Well. The only thing I had to do a minute later was cleaning up all of my debugging effort.

Be careful. Read, think and do. Not do, google, do, google, do, read, think and do after all.
資料結構 — Tree — PHP 實作. 出來混總是要還的, 當本科生在學校學習資料結構時, 我壓根兒就沒聽過這東西。…
By: Ray Lee
Tags: PHP, Trees, Data Structures

Learn more. Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Make Medium yours. Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore
How to use CKEditor 4.0 | Adding CKEditor to webpages (2020)
By: Lu Lier
Tags: Ckeditor, Ikh4ever, Tutorial, Love, PHP

Visit the official CKEditor 4 Download site. For a production site we recommend you choose the default Standard Package and click the Download button to get the .zip installation file. If you want to try out more editor features, you can download the Full Package instead.

Check out below video for demo with simple step to integrate CKEditor 4.0 in Php code:

Topic: How to use CKEditor 4.0 | Adding CKEditor to webpages (2020) Subscribe Us: http://bit.ly/2UaSC5s

Find us on:

If you want to donate some money to our channel, you can send as BTC: 1CG9iWyTNdQswpWAYd8tpbJBqeXdfVFd4r =======================================================

#ikh4ever #CKEditor #Web
What are the good points about being a backend developer?
By: Parsa Mihandoost
Tags: JavaScript, Backend Development, Java, PHP, Development

I think the best point about being a backend developer is to have the creativity to find a solution or make a system that it can work on everywhere on every device which accesses the internet.

Another huge point is you can make an application that your users can work on without having their own device. For example, imagine you would have a note application where you write your to-do list for a day, but you would forget to take your mobile to your office and you would miss your to-do list if that application doesn’t have a web application :). So you need access to your device to use the note application.

Another point is totally technical. But it is so easy to understand that you have the ability to use your favorite language, which you have a good feeling about. You can use Jave like me :) or PHP, Go, C#, Python, etc. But in other big platforms like Android or iOS, you will have the upper hand in the market.
Deploying codeigniter project local live server
By: Suresh Kamrushi
Tags: PHP, Cpanel, Codeigniter, Cpanel Shared Hosting

Deploying Codeigniter project from local to live server

Here I am sharing how you can deploy your CodeIgniter project to production server using cPanel. For making it live you need to purchase domain and hosting space from provider like Godaddy, bigrock or hostgator. Once you purchase you can deploy your project using cPanel.

Deployment can be divided in two major parts as Database and File deployment.

Database deployment

Step 1: Login to cPanel of your hosting provider.

Step 2: Look for “Mysql Database” link under “Database” section and click it to create one.

Step 3: Now you need to create new user for the Database

Step 4: Assign user created to database.

Step 5: Look for “Phpmyadmin” under Database section and click on it.

Step 6: After navigating to PHPmyAdmin dump tables inside database you have created.

Files & Folder Deployment

Step 1: In cPanel look for “File Manager” under “Files” Section. By Clicking you will navigate to the page where you can upload your files and folders.

Step 2: Make sure that you are in “public_html” folder, on “File Manager” page. Now look for Upload link and click on it.

Step 3: Now zip your local code and upload it and provide permissions.

Step 4: Once uploading is completed, come back to file manager. You can see your zip folder in file listing. Right click on folder and select the extract to unzip.

Step 5: Now you can update your “.htaccess” and other config files like, database.php (update the database name, DB username and DB password you created in Step 2 & 3 in database section) and config.php with path details.

Hope It will help someone!!!!
Codeigniter loosing session data after login
By: Suresh Kamrushi
Tags: PHP, Codeigniter, Sessions

CodeIgniter : Loosing session data after login

In Codeigniter after login I am storing all the data into session and redirecting to some controller.But i am loosing all values in that controller and code redirect back to login page.

I try every trick to debug this issue but fail!!! I don’t know from where i got idea to reduce some values from session, Magic.. it start working fine..

Now my question is- why this is happening? Is there any upper limit of values to be store in session in codeIgniter?

Explanation: By default CodeIgniter stores the session data in a cookie, which has an upper limit of 2KB-4KB in size depending on browser. If you are trying to store more than 4KB of data in the session you will start running into issues.

Solution: The easiest solution is to store the session details in the DB.The CodeIgniter session documentation details the process for storing the session in the DB.it’s a matter of setting up a table, and changing a couple of config parameters. Below are the changes you need to do- Update below variable in Config file (application/config/config.php):

$config['sess_use_database'] = TRUE;

$config['sess_table_name'] = 'ci_sessions';

Created new table for storing session-
Quick tips for conversion between Traditional Chinese and Simplified Chinese (繁簡轉換)
By: Dave Wong
Tags: Multilingual, Character Conversion, Cli, PHP, Chinese

TLDR

Open Chinese Convert — opencc https://github.com/BYVoid/OpenCC

opencc is a powerful conversion tools among TC, SC and Japanese Kanji (Not sure what it is, just copied from above github webpage). Please find the detailed description in the official readme.

You may find some official supported language libraries or packages. In some cases if your systems are not implemented with supported languages, you can try to install the executable package in the OS, then use your program language to invoke the command to do the conversion.

In my case, my website was implemented by Symfony (PHP framework). The web server were installed in Debian. The conversion finally works by calling /usr/bin/opencc with Symfony\Component\Process. Codes show below (opencc CLI should be installed in OS):

use Symfony\Component\Process\Process;

$process = new Process(['opencc', '-c hk2s.json']);

$process->setInput("香港繁體到簡體

<pre>並轉換爲臺灣常用詞彙</pre>

<p>臺灣正體到繁體</p>");

$code = $process->run();

if (!$process->isSuccessful()) {

// raise exception or do what you want

}

echo $process->getOutput();

echo "

";

$process->setInput('你好嗎？');

$code = $process->run();

echo $process->getOutput();

Few points to note:

Config file (eg. hk2s.json) is required for it to work properly Input with multiple lines for each conversion works well. (Sounds normal? Try the CLI in shell with stdin may confuse you) Behavior of Process class: run should be call every time, but no re-initialize the instance is required.

Alternative(s) in PHP world:

This PHP package does not work in my case due to the Symfony framework version conflict. For those who use Laravel and latest Symfony, it is definitely worth to give a try.

To invoke the command, exec, shell_exec and proc_open etc. may work well. In my case, I have Symfony and Symfony\Component\Process is handy. I saved time and made the codes concise without using above PHP functions.

Please feel free to comment.

如需要中文解釋，請告知。
How to make Inspector work on Laravel Vapor — Verifarma.com case study
By: Valerio Barbera
Tags: Inspector, AWS, Monitoring, Laravel, PHP

In this article I’ll show you the code implementation to make Inspector work when your Laravel application is deployed on the AWS serverless environment using Vapor.

The launch of Vapor was a big news for the whole PHP/Laravel ecosystem. It allows developers to deploy Laravel applications on AWS Lambda environment, the serverless infrastructure of AWS, without the need to be an expert DevOps, or cloud engineer.

With the aim of eliminating the problem of servers scalability, it brings some complexities that you need to deal with. Serverless execution environment isn’t the same of classic server, furthermore it’s not so easy to customize if you need some additional configuration.

Verifarma.com platform is built on top of Laravel and deployed in the AWS serverless platform using Vapor. They are leader and specialist in traceability and product identification, to improve efficiency throughout the distribution chain. The company today, track and trace leaders in the region and with rapidly growth in Europe, present in 23 countries.

They are one of our best customers that monitor Code Execution Flow in their application with Inspector.

Martín Lejman, lead developer in Verifarma, wrote me about two issues using Inspector when the application is deployed through Vapor in AWS Lambda.

“async” transport doesn’t work. Nothing appears in the dashboard, so they should be use “sync” transport, but it’s suitable for debugging pourpose not for production environment. Jobs are not monitored at all. They doesn’t appears in the the processes list regardless of the data transmission method.

Since the beginning Inspector has been appreciated by developers mainly due to its really powerful Laravel package. I’m really gratefull to the community for the support and feedbacks they provided me over time so work with Martin to make Inspector work on Vapor was a really important challenge for me to continue to guarantee a perfect code monitoring experience to all Laravel developers.

Read the original article: https://www.inspector.dev/how-to-make-inspector-work-on-laravel-vapor-verifarma-com-case-study/
Removing index.php from URL of codeigniter in wamp
By: Suresh Kamrushi
Tags: Codeigniter, Codeigniter Development, Wamp, PHP, Wampserver

Removing index.php from url of codeigniter in WAMP

Only three steps are require to remove index.php from url in Codeigniter in WAMP environment.

1) Create .htacess file in parallel to application holder and just copy past the following code:

RewriteEngine On

RewriteBase /CodeIgniter/

RewriteCond %{REQUEST_URI} ^system.*

RewriteRule ^(.*)$ /index.php/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php/$1 [L]

2) Change $config[‘index_page’] to blank in config.php in application folder as below:

$config['index_page'] = '';

3) Enable “rewrite_module” of apache.

Congrats!!! you have configure successfully.

Now you can access your site without index.php in url.

Originally published at http://sforsuresh.in.
Composer Monorepo Without Plugins
By: Gordon Forsythe
Tags: PHP, Composer

The problem: You have multiple services you want to build/ci/deploy. You want them all to have consistent dependencies between them all (one of the big reasons to utilize a monorepo).

Photo by Marius Masalar on Unsplash

It’s not difficult, you just have to think of your project as being a single segmented project. You don’t even have to utilize any extra funky composer plugins which might do weird things like making symlinks to bin commands.

Instead of having a composer.json file in each service, move that up to the level where all of your project directories live and generate a composer.json there.

Now, this part will take a little time… you will need to merge all of the requirements for all of your projects into the new composer.json.

Also in that composer.json, you will need to add autoload definitions for all of your projects… for example:

{

...

"autoload": {

"psr-4": {

"SomeCo\\Billing\\": "billing/src/",

"SomeCo\\Accounts\\": "accounts/src/",

"SomeCo\\Auth\\": "auth/src/",

"SomeCo\\DB\\": "libraries/DB/src/",

"SomeCo\\Config\\": "libraries/Config/src/"

}

}

...

}

Now, when you do your build step, you will run composer install from the new root project. This will build a vendor directory as a sibling to your project directories. To build the individual project, you will copy the vendor directory and the single project to your vm/docker image/whatever. If you have shared libraries, like the above example, you would also copy the libraries directory.

Of course, in doing this, you will have all dependencies from all of your projects available to the single project, but does it matter? It’s not like this is a 5GB node_modules directory (I exaggerate a little).

Now, the next step is likely going to take the most time. In your project, you must re-define where you fetch your autoload.php file from. In many cases, you can find/replace /autoload.php to /../autoload.php , but you should definitely be careful when doing this depending on what your build expects.

The other big change is if you run any commands from the vendor directory, you will have to redefine where they run from {project}/vendor/bin/xyz to vendor/bin/xyz .

Is that it? Well, yeah. The generated autoloader takes care of everything else, and there’s no funky hackery. Of course, yes the autoloader will have references to your other projects’ namespaces, but your individual projects should not be calling other projects’ namespaces.

Another bonus from using this method in development is you can relatively easily run all of your projects from a single set of containers instead of a set for each project.

Don’t forget to commit your composer.lock file! This ensures dependency consistency between development, CI/testing, and production!

Updating dependencies is relatively simple now.

composer outdated

composer update {whatever you decide to}

commit new lock file

You may want to document where certain dependencies are used, so maybe create a DEPENDENCIES.md when you start copying dependencies into the new composer.json.
Benchmark Pux Router VS Mezon Router
By: Dodonov Alexey
Tags: PHP, Router, Benchmark, Mezon

Hello all! The time I shall compare Pux Route with Mezon Router.

As usual we have two cases:

http server accepts request, launches php script, which handles this request, and then all script data uploads from memory. All following requests are processed in the same way. In this case very critical to launch script as soon as possible and we do not have time for long pre-compilations and preparations. Because all of it will be lost after the script will finish working; php script is launching, initiating all internal components (and router is one of them) and then starting processing requests. This case can be organized via for example react-php. It differs from the previous case because we can spend reasonable time to pre-compile routes for faster processing.

First case

// static routes

for ($i = 0; $i < \Mezon\Benchmark\Base::$iterationsAmount; $i ++) {

$router = \Mezon\Benchmark\RouteGenerator::generatePuxStaticRoutes(1000); $result = $router->dispatch('/static/' . rand(0, 1000 - 1));

$result[2]();

} // non-static routes

for ($i = 0; $i < \Mezon\Benchmark\Base::$iterationsAmount; $i ++) {

$router = \Mezon\Benchmark\RouteGenerator::generatePuxNonStaticRoutes(1000); $result = $router->dispatch('/param/' . rand(0, 1000 - 1) . '/1');

$result[2]();

}

Second case

// static routes

$router = \Mezon\Benchmark\RouteGenerator::generatePuxStaticRoutes(1000); $startTime = microtime(true);

for ($i = 0; $i < \Mezon\Benchmark\Base::$iterationsAmount; $i ++) {

$result = $router->dispatch('/static/' . rand(0, 1000 - 1));

$result[2]();

}

return microtime(true) - $startTime; // non-static routes

$router = \Mezon\Benchmark\RouteGenerator::generatePuxNonStaticRoutes(1000); $startTime = microtime(true);

for ($i = 0; $i < \Mezon\Benchmark\Base::$iterationsAmount; $i ++) {

$result = $router->dispatch('/param/' . rand(0, 1000 - 1) . '/1');

$result[2]();

}

return microtime(true) - $startTime;

Results

As you can see Mezon router is in all cases is faster then Pux Route.

What is mezon/router?

mezon/router now is:

framework for routing with 100% code coverage

10.0 points on scrutinizer-ci.com

on scrutinizer-ci.com router is a part of the Mezon Project

Repo on github.com: https://github.com/alexdodonov/mezon-router

It will be great if you will contribute something to this project. Documentation, sharing the project in your social media, bug fixing, refactoring, or even submitting issue with question or feature request. Thanks anyway )
The Retailer: The Ideal PHP WordPress’s WooCommerce Powered E-Commerce Theme 2021
By: Salman Siddique
Tags: Ecommerce, Php Ecommerce, Ecommerce Web Development, Ecommerce Theme, PHP

Price Tag: $59

What’s Included:

Quality checked by Envato

Future updates

Theme hosting offer

6 months of support from the theme developers //getbowtied

You can get an additional 12 months of support at $17.63

In 2013, The Retailer was launched and has over 15,000 downloads to date. As it gets constant updates, it is one of the trustworthy themes available and the developers respond to customer queries and issues promptly. The theme includes multi-language support so that you can build the store in the language of your choice and sell products.

Features:

Catalog Mode

Mobile friendly

Hassle-free Customization

Dual footer widget

Add affiliate products

Not convinced? See more PHP e-commerce themes for your project. Cheers! :)
What are Traits ? And how to use it in simple words ?
By: Aditya Kohli
Tags: Oops Interview Questions, Oops Concepts, Object Oriented, PHP, Traits

I agree ! Even though most of the programmer have deep knowledge of OOPs concept but they some time fail to explain the core concept of Few important terminology of OOPS.

I have made a small effort to explain one of such terms of OOPS which is Trait

— in simple words

“ Traits are something which helps you to reuse the certain portion of your code and prevents you from rewriting same code again and again”

I know its stupidity to explain such a big term in such a short definition .here we go in more depth:

Example :

Suppose You have 5 pages in your website where different stuffs are displaying ,now if you will be asked to set filter on all the pages for lets says color and price.

you have a list of products that you want to filter out based on above criteria (, color price ),So You can create a Filter trait that contains different functions for different filter types (Price,Color). You can then use this trait not only in your one class (as given in the example), but also in all other classes that need similar strategies .

coding example

Lets say my trait file name is filter_trait.php

trait filter{

public function color($category_id) {

echo $blue;

// you can return any result based on on your requirement

}

public function Price($category_id) {

echo $100;

// you can return any result based on on your requirement

}

}

}

=======================

Now the auspicious time has come to Use the above Trait

Having said that lets suppose you have 5 pages where you want to apply filter for color and price,one of the page is lets say category.php and its content is below

class allcategories{

use filter;



}

$o = new allcategories();

$o->Price();

$o->color();

Believe me no miracle is happening above , its a simple thing

i have accessed the function or methods of trait through object of class allcategories.because i wrote a line “use filter” in the class which give me right to access the methods of this trait “which is filter trait ”.

that’s it go ahead in all of your pages and just through the object of declared classes in those respective page use the methods of trait.

:)

DHANYABAAD/THANKS/SUKRIYA
Windows 10 — Cent OS Stream and POP OS base comparison
By: Povilas Brilius
Tags: Laptop, Umidigi A3s, PHP, Etl, Windows 10

Which of them is base development? Currently I’m working on Pop OS, but at the sake and costs only of a Juicy J records, which are playing at the moment at my smartphone collection — downloaded and approved.

Now, switching to the nominal development, enflown in EUR currency format, it’s nothing dominating except its data. So, operating system has to be imperative in its domain. It’s nothing special nor relative that a virtual hosts folder is sitting inside the operating system /var/ or /srv/ prefixed folders, associated — in one or another meaning — warfare and servelet base, which is largely incorrect in the prominent target market stage.

In this case Friedman comes at hand — tasksel is the helping tool to accompany the development stages with the convenient consumption case at which the disparsity is costly to inverene, because everything is coming out ot the box — and happening immediately.
Are you a web developer divided between PHP and Python?
By: Luciano Vettoretti
Tags: Python, Web Development, PHP, Programming, Development

I made this report to make better decisions in my career as a web developer.

I hope this can be useful to other web devs.

This report was compiled in November 2020.

Programming Language Comparison

PHP vs Python jobs and freelance

Python has more open positions today compared to PHP, but PHP is the programming language of most sites.

PHP vs Python salaries

Python pays more everywhere in the world. Sometimes a little more, sometimes a lot more.

But this can vary a lot depending on seniority level. Here I compiled a medium salary ignoring seniority level.

Web Frameworks Comparison

Most Popular Web Frameworks jobs

Here you can see how PHP can win when you specialize in a Web Framework.

PHP Web Frameworks jobs

PHP has a lot of Web Frameworks but you can see the 2 mature winners.

Frameworks ignored due to low or no data: CakePHP, Phalcon, Zend, FuelPHP, phpixie, and Slim.

Python Web Frameworks jobs

Python also has a lot of Web Frameworks, but Django is a winner.

Frameworks ignored due to low or no data: TurboGears, CherryPy, Falcon, Hug, FastAPI, Sanic, and Grok.

Conclusion

After compiling this data I realized that between PHP and Python you will find opportunities, you just need to focus on one web framework to build your career over it.

Of course, it depends on your goal. Maybe you want to focus on specific areas so I encourage you to explore the links below (specially similarteach.com) and explore in which sectors these web frameworks are used.

References

Jobs

Tech Stats

Web Frameworks

Freelancer

Salaries
Configure Php7.1 + Nginx on Amazon Linux 2 AMI
By: Ritesh Singh
Tags: PHP, Nginx, Aws Ec2

Tech Enthusiast, zeal for learning, and explore the new technologies, loves to do automation in today’s Agile world.
Downgrade PHP version in MAC Os
By: Shamshad Zaheer
Tags: PHP, Valet, Laravel

Recently I upgraded my Mac OS and the new OS was having PHP version 8.0 by default.

I had my previous Laravel Project and wanted to browse it, but due its version the project was showing errors. I needed to downgrade my PHP to version 7.3.

Install PHP Version. 7.3

Open your terminal and type the following code to install php version 7.3

brew install php@7.3

Once I was done with installing php version 7.3 I unlink my current php and link the new installed php.

brew unlink php@8.0
Fuzzy keyword search over encrypted data in cloud computing
By: Ankit Wasankar
Tags: Keyword Research, Encryption, PHP, Cloud Computing, Fuzzy Logic

This is my college project, where I developed a mechanism for fuzzy keyword search in the encrypted data. Here I would like to present the outline of the project and also the complete working code for the same.

What is fuzzy keyword search over encrypted data?

Fuzzy search means approximate string matching

For example: languaje is misspelled word which will matched actually with correct word language

Just like when we misspell something in google, then google corrects it.

But this time, we will be searching in the encrypted data.

Use case:

Suppose a User wants to search a keyword language. But User misspelled it as languaje and clicked on search button.

Data in the database is in encrypted form. Now we will try to search the encrypted data for inputted keyword languaje.

So in this project we have generated the process of matching misspelled keyword with encrypted data.

We have used different algorithms like N-Grams creation, Jaccard coefficient calculation and encryption techniques. So, let us see how we can understand and setup the project

Github link for project: https://github.com/ankitwasankar/Fuzzy-keyword-search-over-encrypted-data-in-cloud-computing

What problem is expected to solve using this project — structure and flow of project?

Demonstration of live code — project

Project Structure:

Fig: Image demonstrating the project working and structure explained in video

You can leave the comment below if you have any problem regarding the project or feel free to mail me at ankit.wasankar12@gmail.com for the same. Please do not use this project as a college or university project without notifying me. :)

Any questions or queries, let me know in comments ?