Print without preview in php on thermal pos printer

Print without preview in php on thermal pos printer

After working on week to setup and print directly from php project, I have successfully done it. And I am about to share what I have learn.

Basically these are the stuff I am going to talk about.

  • Running php code to give print command
  • Thermal esc-pos80 printer setup
  • Printer IP address change

Ok, let’s start setting up things to print.

First of all, download escpos-php project from github. Once you are done downloading, delete following files. This is very important, else you will stuck one IntlBreakIterator class not found issue.

  • composer.json file
  • composer.lock file
  • Delete vendor folder if you already run composer command.

Now, you should run composer require command as shown below.

composer require mike42/escpos-php:2.2

Here is the issue you will get if you don’t mention 2.2 version, don’t delete above mentioned files and run composer install directly. If you get this issue start the process from above again.

Fatal error: Uncaught Error: Class 'IntlBreakIterator' not found

Once composer require is done, run composer install command

composer install

Now go to your project/example/interface/ethernet.php file and replace following lines of code.

// Replace
require __DIR__ . '/../autoload.php';
// with
require __DIR__ . '/../../vendor/autoload.php';

// And replace ip address with the one available in your printer.
$connector = new NetworkPrintConnector("", 9100);

If you are using X-Lab Thermal POS80C printer, the default IP address is ““. Once you enter correct ip address and valid vendor/autoload.php file, you are good to go to communicate with printer. Now change the text as per your need to print text in following line of code.

$printer->text("Hello World!\n");

Replace any text you want to print. But remember ⭐️, you need to add \n at the of each line of text, else the text won’t print.

Now we are all done with configuration part. It’s time to give command in action. Make sure the project is in your htdoc folder with a name pos for example. If this is the case, you can give command to printer by visiting following url.


// or for valet user

Voila! You did it.

Now, it’s time to change ip address. If you you have default IP gateway to something different like in your router then you wont be able to give command to the printer as the printer’s default ip address is So, for this you can change ip address to your desired one. X-Lab Kitchen printer has some issue at the moment so cannot access to printer interface from IP address. Instead we can use the interface by windows application. Download following file and open the interface.

You need to connect to the printer by USB first to change the IP address. In the interface also, you will need to select USB option. If USB is not selected, you wont be able to change the IP address. I think rest of the work to change IP address is easy. If not let me know I will update the blog.

So, that’s all guys. I hope this blog is helpful to you. Please do share my blog.


Tags :

Leave a Reply