Shopware best practice while developing is to use events if you want to change or add the behavior of the shop. Some developers are often searching for full event lists of a system. But in the most cases are those lists incomplete. The main reason are dynamic events. It is always a good idea to create a fresh event list for every development task that desires events.
From time to time I need to run a temporary web server on my local operating system. In the most cases only for the some frontend development of small projects or some prove of concept. Installing nginx or Apache is no option.
A small tool to check What is my IP address?. Plus some MaxMind GeoIP data like city, country or longitude and latitude of an IP.
I started developing Magento 2 projects a year ago. My beloved development environment with virtualization via Vagrant was not an option anymore for such a monster application. Turning back the evolution with installing PHP and a webserver locally was not an option either. I needed something faster and Docker was that something. I made the normal Getting started tutorial and it felt good and fantastic, but I was not able to transform the learned knowledge to my current project. This is not unusual if I lern new software that has a huge field of use. It is possible to search for Put my existing application into Docker in the world wide web, but the result can be disappointing. My decision was firm, the current project has to wait until I have lerned on a more advanced but minimal project how I can integrate my project into Docker. Luckely there was the book Docker for Developers from Chris Tankersley. I can highly recommend this book for every PHP developer that needs a small introduction into Docker.
I have implemented the
levenshtein function on my own in plain PHP.
I am working on a small PHP library that should use some new features from PHP 7, for example scalar type declarations and return type declarations. But my current Debian 8 has only PHP 5.6.29 for me at the moment. The unstable distribution sid is no option to me and in general I try to avoid installing a specific PHP interpreter on my OS. Fortunately I need PHP only on the command line to test my library so I can use Docker to switch between the versions.
Sometimes it is necessary to compare a generated PDF file with a given one in PHP. Just to check with one PHPUnit test that your PDF generation works the expected way. But pretty often generated PDF files are equal, but there content isn't the same. For example if you use FPDF the following assertion can fail if the files have different meta data.
$pdfContent1 = file_get_contents('path_to_pdf1'); $pdfContent2 = file_get_contents('path_to_pdf2'); $this->assertSame($pdfContent1, $pdfContent2);
My project website numphp.org is based on the PHP micro framework Slim. There is no nead for a cms or blog system. I just need some static pages and a little bit of logic. My posts on numphp.org are just static html files that will be served with the php function file_get_contents. But I would like to make the posts searchable. The easy way would be a slim route for search that is just checking if the searched query is contained in every post of my blog. But in near future I would like to make also the documentation searchable. So I will use the hooks of the Slim Framework. Hooks are the same as events in other frameworks. You can throw them and listen or observe them.
Two weeks ago I could not find events in the Slim Framework so I made a Pull Requests to add a EventManager to the Framework. But before sending the Pull Request I have figured out, events are just called hooks:)
5 minutes ago I have written a post with a Github Gist. You can embed Gists like this in your posts
But the gist has looked like this
Not bad, but something like this would be better.
$column = $matrix->get('1:3', 5); $matrix->set(3, '1:', $vector);
So I have found the interface ArrayAccess, but it has one big problem. It is not for multidimensional objects.
$column = $matrix['1:3']; $matrix['1:'] = $vector;
I have noticed more and more links to commercial Magento extensions in the comments of my blog. That is pretty normal, cause my Magento extensions aren't free of conflicts with other extensions and people just want to give me a hint. But sometimes I'm not sure if they just want to ask a stupid question and make their link. SEO isn't my hot topic. Everything I know is, good content and backlinks are important. I always visit the website of an comment and sometimes I remove their link to an commercial Magento extension shop. But I would like to disable the links in the comments. So I have decided to make all links in comments not clickable.
Lesti_Fpc has changed in the last month. Some of the changes are part of the code quality. Today I would like to present the tools, that I use to raise the quality of my Magento extension.
In Lesti_Fpc 1.3.2 I have added the possibility to edit the cacheTags and Parameters via an event. The idea of the Fpc was very clear and simple, but every day I get requests from developers with problems, that aren't that simple. For example oblomovx wanted to Disable Cleaning of Categories after product save. Maybe 98% of all Fpc users didn't need the possibilty to disable this functionality. Or riznmage wanted to Add AJAX parameter to make a differnce between requests that are made by ajax and normal requests. I can understand the need of such a thing, but on the other site I can't implement every crazy idea or I just think that it is wrong to make a ajax request on a action that isn't normally made for it. To let the Fpc simple, but also give those people the possiblity for there workflow I have made it like Magento. I have dispatched some events to work a little bit more advanced with the behavior of the Fpc.
Today I would like to make a small review about the book Magento Product Types: Developer's Guide from Oleg Ishenko. I know Oleg since 3 years. He was my Chief Technical Officer at a Magento shop in Berlin. This book is not an introduction to Magento. With this book you will get deeper into product types of Magento. You will get a introduction to the core product types in Magento XML configuration. Every really interesting type is included Configurable Product Type, Bundle Product Type, Grouped Product Type and Downloadable Product Type. The author will show you after the core product types, how to create an own custom product type. Every Type has his own chapter and at least one tutorial with sample code in a git repository. Oleg also explains mostly every kind of configuration that Magento uses to define types. You should take a look at this book, if you want to know more about the complexity of products in Magento. And mostly everything revolves around products in e-commerce.
I did start building Lesti_Fpc2. I always wanted a flexible and most compatible solution for Magento. That was never easy. So in Lesti_Fpc I did use the event controller_action_layout_generate_blocks_before as anchor. Just to explain, as anchor I mean the point were the Full Page Cache stops normal behavior of Magento and sends cached response. Normally you want to have this anchor as early as possible. My anchor was very flexible, but also not that fast as I expected.
I just was thinking about Fuzzy Search and why it isn't possible in mysql. Sure there is SOUNDEX in Mysql, but that's not what I want. I want search results from the Levenshtein distance. But Mysql didn't has such a function. I guess the best solution would be a search server like SOLR or Elasticsearch. But on a shared hosting you haven't such a cool thing. A possible solution is to return all results of the table and work with the levenshtein function of php. I guess in the most cases this is the best solution. But I just want to test an other way, I guess maybe a very stupid way.
The Welcome Message in Magento 1.7 is a problem for Lesti_Fpc. You can find the reason in app/design/frontend/base/default/template/page/html/header.phtml.
<!-- ... --> <p class="welcome-msg"><?php echo $this->getWelcome() ?> <?php echo $this->getAdditionalHtml() ?></p> <!-- ... -->
The welcome message is just a function of the header block. Lesti_Fpc needs the welcome message in a seperated block. In Magento 1.8 this is solved and the name of the block is welcome. In Magento 1.7 there is a semi-solution in core, we just have to give a little help.
I have released Lesti_Fpc 1.1.5. What is new in this version? I have add a new field in the configurations. Miss Uri Params, not a really creative and good name. The idea behind this parameters is: No request with these parameters will be cached. For example:
It's getting a little bit complicated. All Miss Uri Param will be seperated by comma and every parameter is sperated with an = from a regular expression. Every request with the parameter limit as an integer will miss the Fpc. I know it makes the configurations complexer, but I guess it will help somebody.
The current Magento2 version is 18.104.22.168-dev45 and I would like to build a simple HelloWorld! extension. I guess the current version isn't that different to Magento1 and maybe it doesn't make that much sense to write this right now, but I just want to show the little difference in this moment.
Today I want to make a little review about PHP Data Persistence with Doctrine 2 ORM from Michael Romer. Like I said in a few posts ago, I just developed Magento Shops and worked with the Zend Framework. But there are so many cool libraries and frameworks for webdevelopers that I never tested. One of these things is the Doctrine Project.
"The Doctrine Project (or Doctrine) is a set of PHP libraries primarily focused on providing persistence services and related functionality."There isn't any other book outside for Doctrine. Maybe, because the documentation is very good. But I wanted a german. I know, I'm presenting the english one, but I did read the german version. If I buy a book, I expect from the author not only knowledge about the a framework or library. I also expect things like common styleguide and some practical experience. The book is published by leanpub. A very cool publisher for ebooks about IT stuff. You just have to write a ebook and can publish it over leanpub. The books will be published in the working progress, often you just have 10% of the book and it will grow. They are not that expensive, but the main problem is, the books aren't that professional.
I just wanted to write my first Hello World extension in Magento2, but it wasn't that easy. The normal way in Magento is to create a <module>.xml in app/etc/modules. For example my extension should have the Name Lesti_HelloWorld, I would create app/etc/modules/Lesti_HelloWorld.xml with the following content:
<?xml version="1.0"?> <config> <modules> <Lesti_HelloWorld> <active>true</active> <codePool>community</codePool> <depends> <Mage_Core/> </depends> </Lesti_HelloWorld> </modules> </config>
I stared the repository of magento2 since 1 year, but I never did take a look at it. Today I wan't to change this. My current status is commit a15ecb31976feb4ecb62f85257ff6b606fbdbc00. Maybe in a few weeks all of my post isn't the latest. Let's install magento2.
Since version 1.1.1 of Lesti_Fpc I get more support requests for the layered navigation. I did change the behavior of key generating in Lesti_Fpc to get more hits in the cache. I added the new field Uri Params in the configurations and wrote a post about it. This post is all you need to get your layered navigation work, but I guess it would be better to explain it again an example.
Lesti_Fpc needs the name_in_layout of a block to make that block lazy or dynamic. Magento needs a unique identitfier for every block in the layout. That is the Name in Layout of a block. You can get this name with the following function.
$blockName = $block->getNameInLayout();
Or you can find the name in the layout.xml of your extensions. For example the app/design/frontend/base/default/layout/checkout.xml.
<!-- ... --> <block type="checkout/cart_sidebar" name="cart_sidebar" template="checkout/cart/sidebar.phtml" before="-"> <!-- ... -->
The searched attribute is name.
I have changed the keys in Lesti_Fpc 1.1.1. There was a problem with parameters in the Cache. Not a real problem, but the cache has produced too much keys. That means, more memory for the cache, but the real problem was, the cache had too much misses.
Events in magento are very cool. Mostly events make it possible to build very modular extensions for magento. In my first steps, I always searched for a full list of magento events. The problem with these lists were, they aren't complete and outdated. And you will never find dynamic events like this.
A few weeks ago, I wanted to build a little analytics tool. The idea was to send anonym data , to improve the performace of a magento extension (only with the permission of the shopowner). A little bit like mozilla or PhpStorm asks you after the install. But before building a static and very special webservice only for my interests, I decided to search for a tool like this. A tool that can collect requests. And I found Piwiki. A free Web Analytics Software. All I needed was a mysql database and php. I installed it after 5 minutes and was ready to check every request on my blog. I can see every visitor and can see the main problems of my website. All these datas are hosted on my server. There was also a app for my smartphone. There are many plugins for magento, wordpress and so on. I'm that happy with this tool, that I wanted to write a little post about it.
In Lesti_Fpc 1.1.0 I created a new type of dynamic blocks. I call them lazy blocks. First I will explain what dynamic blocks are and what the difference to lazy blocks is.
Many full page caches are in front of Magento. Often Magento doesn't see the request. That makes external caches very fast. You only have to define a process in front of magento and send your own request. But external caches have to reload dynamic content with ajax and aren't that flexible. Lesti_Fpc has an other workflow.