লারাভেল ভ্যালে ইনস্টলেশন


গত পরশু(৭ মে, ২০১৬) লারাভেলের নতুন ডেভেলপমেন্ট এনভায়রনমেন্ট লারাভেল ভ্যালে(Valet) রিলিজ দেয়া হয়েছে। এটা ম্যাক অপারেটিং সিস্টেমের জন্য একটা সিম্পলিফায়েড ডেভেলপমেন্ট এনভায়রনমেন্ট। এটা ইনস্টল এবং ব্যবহার করা খুবই সহজ। আপনি শুধুমাত্র আপনার পিসিতে একটি প্রজেক্ট ইনস্টল দিবেন এবং প্রজেক্টের ফোল্ডারের নামের সাথে .dev যুক্ত করে ব্রাউজারে সেটি ব্রাউজ করতে পারবেন। ভ্যালে কি, এটা কিভাবে কাজ করে, এটা নিয়ে এডাম ওয়াদান একটি চমৎকার ভিডিও তৈরি করেছেন। সেটি দেখুন।

যারা এর পূর্বে লারাভেলের হোমস্টিড ব্যবহার করতেন, তারা নিশ্চয়ই জানেন সেটা ব্যবহারের জন্য আপনাকে অনেকগুলো ডিপেন্ডেন্সি ইনস্টল করতে হয়। যেমন- ভার্চুয়াল বক্স, ভ্যাগরেন্ট ইত্যাদি। এগুলি ইনস্টল করার পর লারাভেলের হোমস্টিড বক্স ইনস্টল করতে হয়। এই ফাইলগুলি আকারে বেশ বড়, প্রায় কয়েক গিগাবাইট। তাই ইনস্টল করতে প্রচুর সময় লাগে। এরপর প্রত্যেকটা সাইট এড করার সময় হোমস্টিডের yaml ফাইল এডিট করতে হয়। এরপর সেটা প্রভিশনিং করে আপনার মেশিনের hosts ফাইল এডিট করতে হয়। সে তুলনায় ভ্যালে ইনস্টল করা খুবই সহজ এবং এর সাইজও অনেক ছোট। এটা পিএইচপির বিল্ট-ইন সার্ভার ব্যবহার করে, ফলে এটা ব্যবহার করার জন্য আপনাকে এপাচি, এনজিনেক্স বা এ ধরনের ওয়েব সার্ভার ব্যবহার করতে হবে না। শুধুমাত্র পিএইচপি এবং মাইসিক্যুয়েল ইনস্টল করা থাকলেই আপনি ভ্যালে ব্যবহার করতে পারবেন। চলুন দেখি একেবারে নতুন একটি ম্যাক মেশিনে আপনি কিভাবে ভ্যালে ইনস্টল করবেন।

প্রথমেই আপনাকে হোমব্রু ইনস্টল করতে হবে। এটা ম্যাকের জন্য একটি প্যাকেজ ম্যানেজার, যার মাধ্যমে আপনি বিভিন্ন ডেভেলপার টুলস খুব সহজেই ইনস্টল করতে পারবেন। আপনি যেহেতু ম্যাক ইউজার, অবশ্যই এটা আপনার মেশিনে ইনস্টল থাকা উচিৎ। এটা ইনস্টল করা খুবই সহজ। আপনি শুধুমাত্র নিচের কমান্ডটি টার্মিনালে চালালেই হবে।

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

এরপর এর মাধ্যমে পিএইচপি ইনস্টল করতে হবে। এটা করতে নিচের কমান্ডটি রান করুন-

brew tap homebrew/dupes
brew tap homebrew/versions
brew tap homebrew/homebrew-php
brew install php70

যেহেতু আপনি ম্যাক অপারেটিং সিস্টেম ব্যবহার করছেন এটিতে ইতোমধ্যে একটি পিএইচপি ভার্সন ইনস্টল করা থাকে। উপরের কমান্ডের মাধ্যমে আপনি পিএইচপির লেটেস্ট ভার্সন পিএইচপি ৭ ইনস্টল করলাম।

এবার কম্পোজার ইনস্টল করবেন নিচের কমান্ডের মাধ্যমে-

brew install composer

এবারে মাইসিক্যুয়েল ইনস্টল করবেন নিচের কমান্ডের মাধ্যমে-

brew install mysql

মাইসিক্যুয়েল সার্ভার স্টার্ট করতে নিচের কমান্ডটি দিতে পারেন-

mysql.server start

মাইসিক্যুয়েলের যে ইনস্ট্যান্সটি ইনস্টল হয়েছে সেটার ইউজারনেম root এবং পাসওয়ার্ড হিসেবে আছে একটা এম্পটি স্ট্রিং। আপনি টার্মিনাল থেকে নিচের কমান্ডের মাধ্যমে মাইসিক্যুয়েল এক্সেস করতে পারবেন।

mysql -uroot

এবারে লারাভেল ভ্যালে ইনস্টল করার পালা। এর জন্য টার্মিনালে নিচের কমান্ডটি দিন-

composer global require laravel/valet

ইনস্টল হয়ে গেলে প্রথমে ভ্যালের বিভিন্ন ডিপেন্ডেন্সি ইনস্টল করুন নিচের কমান্ডের মাধ্যমে-

valet install

এই কমান্ডটি আপনার মেশিনের সুডো পাসওয়ার্ড চাইবে কারন এটি dsnmasq নামে একটি ইউটিলিটি আপনার সিস্টেমে ইনস্টল করবে। এটি করা হয়ে গেলে আপনি যে ফোল্ডারে আপনার প্রজেক্টগুলো রাখতে চান, সেটিতে প্রবেশ করুন। তারপর নিচের কমান্ডটি দিন।

cd project-folder
valet park

ব্যস, আপনার সব কাজ শেষ। ধরুন আমরা এখন একটি নতুন প্রজেক্ট তৈরি করবো ব্লগ নামে। তাহলে প্রথমে এই নামে একটি লারাভেল প্রজেক্ট তৈরি করি।

composer create-project laravel/laravel blog --prefer-dist

এবার আমরা ব্রাউজারে যদি blog.dev ব্রাউজ করি তাহলেই প্রজেক্টটি দেখতে পাবো।

শুধু তাই নয়, আপনি যদি এখন এই প্রজেক্টটি আপনার কো-ওয়ার্কারদের সাথে শেয়ার করতে চান সেটিও করতে পারবেন খুব সহজে। আপনি ব্লগ প্রজেক্টের ডিরেক্টরিতে প্রবেশ করুন। তারপর নিচের কমান্ডটি দিন।

cd blog
valet share

এই কমান্ডের মাধ্যমে আপনি একটি ইউআরএল আপনার টার্মিনালে দেখতে পারবেন। এছাড়াও সেটি আপনার ক্লিপবোর্ডে কপি করা অবস্থাতেও পাবেন, শুধুমাত্র পেস্ট করলেই চলবে। কি অসাধারন!

ভ্যালে শুধুমাত্র লারাভেলই না আরো অনেক পিএইচপি প্রজেক্টের সাথে আউট অব দ্য বক্স কাজ করে। এছাড়া আপনি চাইলে নিজেও যে কোন প্রজেক্টের জন্য ভ্যালে ড্রাইভার তৈরি করে নিতে পারেন, যা আসলে খুবই সহজ। বিস্তারিত জানতে ভ্যালের অফিশিয়াল ডকুমেন্টেশন দেখতে পারেন।

আপনি নিশ্চয়ই অবাক হয়েছেন, লারাভেল ভ্যালে কিভাবে এতসব করে? এটার কার্যপদ্ধতি সম্পর্কে বিস্তারিত জানতে এখানে দেখতে পারেন।

Adminer, a great tool for accessing databases


Most of the web developers specially who used to write code in PHP, including myself using phpmyadmin for a very long time for database management. I myself used this tool for last 6 years or so. But recently I was introduced to a great tool called adminer while facing problem to install phpmyadmin on homestead box.

adminer-logo

Long story short, it is a single php file which has almost all the functionality that phpmyadmin has with a bunch of other useful features. Also it supports mySQL, SQLite 2 & 3, PostgreSQL, Oracle, MS SQL, Firebird, SimpleDB, MongoDB and ElasticSearch where phpmyadmin only supports mysql. It is also extremely lightweight and portable as it is only one file. The compressed file is only 231 kB and if you use the English version without 36 other language’s translation it turns into 167 kB only. If you use mySQL only, then you reduce the size to 155 kB for translated version and 94 kB for english only version. That’s insane.

You can find a full comparison with phpmyadmin to their site. It can work with various plugins and has a bunch of themes. It’s released under GPL2 and Apache License and it’s totally free to use.

Besides that, it has a Debian package, Arch Linux package, WordPress plugin, Drupal module, Joomla extension (1, 2) Moodle plugin, TYPO3 extension, CMS Made Simple Module, Laravel, AMPPS, and Nette package.

After finding this, I just uninstall phpmyadmin form my machine and immediately switched to adminer. Hopefully, you would like it also.

Setting Up Atom Editor for Software Development – 04


Today I am going to talk about a very important topic, and that is Lint. In computer programming, lint is a Unix utility that flags some suspicious and non-portable constructs (likely to be bugs) in C language source code; generically, lint or a linter is any tool that flags suspicious usage in software written in any computer language.

According to wikipedia

In computer programming, lint is a Unix utility that flags some suspicious and non-portable constructs (likely to be bugs) in C language source code; generically, lint or a linter is any tool that flags suspicious usage in software written in any computer language.

Thats bookish knowledge, lets make is a little bit easier to understand. Linter will help to prevent various typo and organize your code in various coding standards.

I am a web application developer and I use php and javascript almost everyday. So, in this episode I am going to show you how to use linter in these languages. First of all you have to install the base package for atom linter. It will give you the base functionality and it’s a bridge for using specific linter package for various language. You can install linter by typing apm install linter or from settings’ package installer.

This linter package supports a lot of different languages. All the supported packages and ducumentation can be found on http://atomlinter.github.io/

I use only some packages that I use for my day to day job. Let me introduce those one by one.

At first lets talk about HTML linter. I use linter-htmlhint package for this. This package is just a bridge between atom and famous htmlhint package. You can install it via apm install linter-htmlhint. It assume you pc has already htmlhint installed. If not then you could install it through npm install htmlhint -g and then give it’s path to htmlhint package settings. I assume your machinealre If you don’t find the path, then type which htmlhint on your terminal and paste the path to the settings.

After that I am going to talk about csslint. It’s almost the same process, just install it form terminal with apm install linter-csslint and configure it same as previous package.

You can install jsonlint and bootlint for linting json and bootstrap code. Install it by typing apm install linter-jsonlint and apm install linter-bootlint. Configuring process is exactly the same.

linter

There are two popular linter for javascript. One is jshint and other is jslint. They are not better from one another, they are just different. I personally use jshint. Install it from terminal by typing apm install linter-jshint and then give it’s path in settings just like the previous one.

linter

I use php a lot and php has some popular linter package. But I think PHP code sniffer is the most popular and one of the best package for php. You can install the package form terminal by typing apm install linter-phpcs. It assume youe machine already has phpcs installed. If not you could install it in a number of ways. One of the popular way is to install it through pear. Just type pear install PHP_CodeSniffer and you are good to go. But I prefer another way, and it’s through composer. If you are a php guy, I assume you have familiarity with both pear and composer. You can install it from terminal with composer global require "squizlabs/php_codesniffer=*" command. Then just give the path of phpcs to the settings of the package.

Thats it. From now on if you do something wrong while typing, atom linter will show errors.

Thats all for today. Peace.

Setting Up Atom Editor for Software Development – 03


In this episode I am going to talk about some basic package of atom. I told you earlier that atom is a text editor and it is not as feature rich as other IDEs like PhpStorm or Netbeans. But you could give it additional functionality with various packages.

First I am talking about a package that will give a nice look to your editor. The package is called file-icons. A number of icons and colors are provided by default for a range of common file types. If you have file that you would like custom icons for you can easily add this yourself. You can install it with this command- apm install file-icon or from settings menu’s install tab.

file-icon

The next package is inspired by Sublime Text’s minimap feature. Actually I am a very big fan of minimap and I use this feature in every editor I use. Install it through apm install minimap or via settings menu. From settings menu you can change the position either in left or right and enable or disable colors. You can also scroll via clicking on minimap and also automatic hide minimap pane.

minimap.png

Now I am talking about a very famous package that you might already familiar with. It is none other emmet, which was used to known as zen coding. It will boost up your development speed a lot. You can find the documentation and installation instruction on their official website emmet.io

What emmet does is with a keypress it expand HTML tags. like if you type a&gt;img and then press tab or Ctrl+e then it will expand to <a href=""><img src="" alt=""></a> which is very handy. But for atoms default keybinding, tab is not working all the time. You could add the following line to you config.cson file to work it properly.

# Emmet
'atom-text-editor:not([mini])':
'tab': 'emmet:expand-abbreviation-with-tab'

I generally use markdown instead any rich text editor like MS Word or Libre Office. If you are like me Markdown preview plus can be a great tool for you. Just install the package from package installer and press ctrl+shift+m to view preview. For mathematical equation rendering press Ctrl+shift+x and see the magic.

Thats all for today. See you guys in the next episode. Piece.

Setting Up Atom Editor for Software Development – 02


Let’s start configuring atom’s look and feel. Atom comes with two types of visual themes. One type is UI theme and other is Syntax theme. UI theme defines the look and feel of the editor and syntax theme defines the syntax highlighting.

Atom comes with a bunch of UI themes, actually four to be precise. The default one is One Dark. I like it most. Actually I like this theme so much that I used it with my other editors even with my terminal. There are some more popular themes for atom especially material theme is very popular. You can find any themes on atom’s official theme portal.

Now lets talk about syntax theme. There are mainly two types of syntax theme, the light one and the dark one. I personally a very big fan of dark themes, I think most of the developer is. Currently I am using One Dark syntax theme. I actually change syntax more very often. Seti syntax is probably the most popular theme of atom. Material theme is also popular. I used them both. You can find tons of other theme on atom’s theme directory. I liked a syntax theme named Space Peacock very much, you can give a try with that too. I hope you would love that.

 

Screen Shot 2016-03-03 at 11.54.20 AM

One Dark theme

 

Solarized is also a very popular theme for any editor or IDE and it is very pleasant to eyes. In facts most of the popular themes are available for every editor or IDE.

Installation of theme is very strait forward. You can install them via settings menu. You can go to settings menu by pressing Cmd + , on mac or Ctrl + , on windows or linux. Go install tab and search your desired theme and then press install. You are good to go. Then form the settings menu you just change the theme.

Screen Shot 2016-03-03 at 11.48.07 AM

Atom also comes with a command line package Screen Shot 2016-03-03 at 11.51.43 AMmanager called apm. After installing atom you can go your terminal and type apm -v to verify. You can install theme vai apm also. I actually prefer using amp. You can install theme via apm also. Just type apm install theme-name and press install. Theme will be installed.

That’s all for today, will talk to you on the next day. Peace.