Categories
Magerun

Released n98-magerun Version 1.95.0

We released a new version of n98-magerun for Magento 1 (for Magento 2 have a look at https://github.com/netz98/n98-magerun2).

There are some features and improvements which we are try to explain.

Alternative project config

Many of you don’t use the standard project structure where the root folder of the project is also the webroot of the virtual host.
In the last releases we added support for a “stop file” which stops n98-magerun’s Magento root detection. If the file is found it contains a relative path to the webroot like “www” or “htdocs”.

In this release we added support to place a project config in the project root folder. If a “stop” file was found we search for a “n98-magerun.yaml” in the same folder.

An example structure could be like this:

  • #444 Added support to place .n98-magerun.yaml file in the same folder as “n98-magerun” stop file. (by Christian Münch)

PSR-4 support for modules

It’s now possible to use PSR-4 compatible autoloader of embedded composer.

This can reduce the numbers of sub-folders inside a module.

The autoloader definition in n98-magerun.yaml is nearly the same.

The only thing we changed was to change “autoloaders” to “autoloaders_psr4”. The trailing “\” at the namespace definition is required.

If psr-4 autoloader is used we don’t need to create empty “Foo\Bar\Zoz\” folders. The autoloaders will load directly from defined target folder (in this case “src”).

  • Added support for PSR-4 autoloading. (by Christian Münch)

New dev:console !!!

With release 1.56.0 we added the dev:console command which was a greate feature. The problem with the dev:console command was that we used the PHP internal interactive console which shows a different behaviour on some systems.
We was not able to fix that. Now we replaced the dev:console command with psych a userland code PHP shell.

You can run the dev:console with n98-magerun.phar dev:console.

Init Magento

dev_console_initialization

PHPDoc

dev_console_doc

Local Variables

dev_console_dump_variables

dev_console_local_variables

Show Code

dev_console_show

  • Added new Psy\Console. Replaced dev:console command. (by Christian Münch)

Fixes and Improvements

  • #465 checking for presence of Mage.php file in list of files searched for since Magento 2 no longer has a god class (by David Alger)
  • #466 Configuration loader fatal error (by Tom Klingenberg)
  • #472 Allow setting unix socket in host component (by Melvyn Sopacua)
  • #474474 Add index event tables to @ids table group of the db:dump command (by Aad [Mathijssen)
  • #475 Add importexporttemp table group for db:dump command (by Aad Mathijssen)
  • #478 Improve sys:cron:run input handling (by Aad Mathijssen)
  • #482 Infinite loop on n98-magerun script:repo:run –no-interaction (by Tom Klingenberg)
  • #483 Cache clean “race” condition (by Jason Potkanski)
  • #488 Fix wording (by will-b)
  • #496 Upgrade PhpStorm (by Rafael Corrêa Gomes)
  • #506 backend_type in eav:attribute:list (by Steve Robbins)
  • Added debug logging if project config file is loaded. (by Christian Münch)
  • Fixed magento detection. Try every command if Magento was found. (by Christian Münch)
  • Removed Magento 2 installation source. (by Christian Münch)
Categories
Magerun

n98-magerun2 – Project Update 2015-02

n98-magerun2 Updated

This is short project update about the current progress of n98-magerun for Magento 2.
We ported some commands and backported features planned for next n98-magerun1 release like the PSR-4 namespace support or the alternative project config.

Compatibility to lastest M2 Beta6

The latest Magento 2 develop version comes with some code refactorings.
One was to move the interface \Magento\Store\Model\StoreManagerInterface to Magento\Framework\Store\StoreManagerInterface which broke some n98-magetun2 code. The fix was easy to find because all store/website command unit tests failed. So we could
find an fix the commands.
This means that you should update your Magento 2 Test-Installation to Beta 6 if you use the latest n98-magerun version.

After writing this blog post Magento published Beta 7. It seems that latest n98-magerun2 version is already compatible.

PSR-4 support for modules

If you create n98-magerun2 modules you can now use PSR-4 autoloading.

Example:

Please note that PSR-4 namespaces must end with a slash.

Ported commands

We ported the following commands:

  • sys:repo:run
  • script:repo:list
  • sys:cron:list
  • sys:cron:run
  • sys:cron:history

Alternative project config

You can now place an alternative project config file in the project root folder. This was an often requested feature for n98-magerun. We will have this features also in the next n98-magerun1 version.

It’s now possible to place a new config file .n98-magerun2.yaml in the project root. Please note that project root can be different to your Magento root.
The .n98-magerun2.yaml file will only be loaded if “stop file” .n98-magerun2 (the file with relative path to the Magento root folder) was found.

Example:

Installer fixes

The installer can now import and install the sample data. We fixed a problem with minimum-stability settings.
Now you should be able to install Magento 2 with pleasure.

Total progress

The first milestone (port all commands from version 1 to version 2) is now 34% completed.

Categories
Videos

Magento 2 installation

Downloads all… Magento source, composer, …

Categories
Magerun

n98-magerun2 – Project Update 2015-01

n98-magerun2 Updated

After some busy days and a intermediate update of n98-magerun V1 i ha time to give the code base a little bit love.
In the meantime i got help from EliasZ who ported a lot of n98-magerun commands to V2.

Newly ported commands

This command were ported in the last 30 days:

  • cache:clean
  • cache:enable
  • cache:disable
  • cache:flush
  • cache:list
  • config:get
  • config:set
  • config:delete
  • dev:symlinks
  • dev:template-hints-blocks
  • dev:template-hints
  • sys:maintenance
  • sys:setup:compare-versions
  • sys:setup:run
  • dev:module:list
  • dev:module:observer:list
  • script
  • shell
  • self-update

Feel free to test the command in your Magento 2 installation and send us pull requests/issues if
you find a problem.

Automatic dependecy injection

As we started one of the first things was to fetch the Magento 2 ObjectManager which is needed
to create instances of Magento 2 objects.
In n98-magerun we can use the object manager (inside a command) as service locator.

Example:

Now we improved the system a little bit and implemeted a new system for automatic dependecy injection.
It’s very simple and simiar to constructor injection in Magento 2 modules.
We introduced a new magic method inject. If this method is defined in a command class we automatic
parse the arguments and try to inject all objects.
Another side effect is that Magento is initialized and no manual “initMagento” call is needed anymore.

Example:

Use the inject method if you need some Magento objects in your command. If the method is not available
the command behavior is like before.

We don’t removed the getObjcetManager method.

Statistics

As written in previous post we first try to port all commands from Version 2. The milestone progress has reached 30%.

Categories
Magerun Tips

Creating a local Magento repository for n98-magerun

Milan Simek created a blog post about creating your own local repository of sample-data and Magento installers.

http://plugin.company/blog/creating-local-magento-repository-n98-magerun/

Categories
Magerun Tips

Send all queued emails

mail_cron

Since Magento CE 1.9.1 all “new order emails” are queued. A new defined cronjob core_email_queue_send_all is now processing the queued emails.
During development it’s not very handy to run the job by a minute based scheduler. In this case you can use n98-magerun to start the cronjob manually.

Categories
Magerun

Released n98-magerun Version 1.94.0

n98-magerun-1-94-0

Today we released a new version of n98-magerun (1). This is the first stable release of 2015.
Most of the time we spent in development n98-magerun2 but this don’t mean that 1.x branch will get no new features.

Giftcard management

Steve Robbins created a list of commands to work with EE Giftcards

Before any creation of new gifcards you need a generated giftcard pool. This can be done in Magento Admin system configuration (System -> Configuration -> Giftcards -> Gift Card Account General Settings) where you can define i.e. the format of the generated codes.
If you don’t like to change the defaults or have configured the giftcard pool already a handy new command gitcard:pool:generate can be used.

If a pool is available you can create new cards with the giftcard:create command by passing the amount as argument.

Informations about an existing giftcard can be obtained with giftcard:info command.

  • #443 Create, view, and remove gift cards (by Steve Robbins)

Show Cronjobs history in your timezone

With new –timezone option it’s now possible to see the cronjob history in another timezone than UTC+0.

Examples:

  • #416 Convertstimes to local or specified timezone (by Steve Robbin)

Disable commands by config.

In some cases it’s possible to have a command conflict. One case is if you have two 3rd party modules which define the same
command name (not PHP namespace).
In such cases you are now able to disable a command by it’s fully qualified class name over any config.
This is also useful for providers which install n98-magerun and like to disable some commands.

Example:

This will disable the db:drop command.

Smaller fixes and improvements

  • #428 Add newsletter table group for db:dump command (by Christoph Aßmann)
  • #441 config:dump produces invalid xml (Andrew Stayart)
  • #452 Added .DS_Store to .gitignore (by Hervé Guétin)
  • #462 dbHost not respected #462 (by Achim Rosenhagen)
  • #463 Fixed missing sprintf when creating Exception in sys:cron:run command (by Tim Eydamos)
  • #464 SampleData in Version 1.9 are not downloading (by Rafael Corrêa Gomes)
  • #453 Add store parameter to template hints commands (by Hadrien Collongues)
  • Removed Magento 2 bootstrapping -> Moved into n98-magerun2
Categories
Magerun

n98-magerun2 – Project Update 2014-12

n98-magerun2 Updated

Last month we started the development of Version 2 of n98-magerun which will only run with Magento 2.
After the official release of Magento 2 Dev-Beta 1 we must change some parts of the tool according to some refactored stuff in Magento 2.
If you checkout the code on github please note that we port any command one at a time.
This is why we don’t only add the same features, we also refactor all the code we put into the n98-magerun2 code base.

As one of the first thing we did a complete refactor of the “install” command.

Installer

The new installer got a big refactoring. All the code is now organized in sub-commands. Sub-Commands are a new feature which should help us to cluster code of big commands (like the installer) into peaces of small code which is much better to extend and maintain.

The sub-command classes can be found in new namespace N98\Magento\Command\SubCommand.
There is an interface which must be implemented and a Abstract class which does the most the of work for you.

n98-magerun2-subcommands

The main installer commands like like this now:

Is that great? I hope you can see the difference.

The new installer command works like in Version 1 with one big difference. The main repository will be cloned and
all depencies are now fetched by composer. If you have composer installed on your system and n98-magerun2 can find
it we use the existing composer to install packages. If composer cannot be found we download and install composer
automatically in the new created Magento 2 root folder. So you can use composer after the installation.

Currently we found an issue in the sample data composer package. We hope the issue will be resolved soon.

Test System

We setup Travis for our QA. Like Magento 2 we dropped support for 5.3 and test only PHP 5.4 and PHP 5.5.
Magento 2 requires also at least MySQL 5.6. This is not available on Travis servers. How can we test now with Travis?
We looked at Magento 2 Travis file and found the solution. Travis supports installing 3rd party packages on testing platform.
This can be done, because after every build a snapshot of the system (before the test) will be restored.
So we copied the travis file code into ours and now we are able to test the complete n98-magerun installation.
Thanks to the Magento 2 core developers for the great setup.

The unit test framework is now also up to date to start test driven development.

https://travis-ci.org/netz98/n98-magerun2/builds/45283372

DB Commands

We already ported all DB related commands from Version 1.

  • db:console
  • db:create
  • db:drop
  • db:dump
  • db:import
  • db:info
  • db:maintain:check-tables
  • db:query
  • db:status
  • db:variables

There are some changes from Magento 1 to Magento 2. The first thing we investigated was the removed app/etc/local.xml file.
The config is now saved in the new file app/etc/config.php. This change to PHP offers us some new capabilities. The config can now contain ENV vars which is great in combination with i.e. docker.
The bad part is that other systems cannot process them like the old XML file.

In n98-magerun2 we changed the DatabaseHelper. The base config is now loaded in MagentoHelper.
If you need the base config you can load the config array in a command without Magento initalization.

The DB part could be refactored so that no code-change is needed.
The DB settings can be loaded like in “n98-magerun 1”.

If you are wondering where the tests are located… we added a new “dev” folder in the project root.

Please help us to test the n98-magerun2 code. We also accept pull requests for the develop branch. Please don’t update
the phar file. The phar file only exists in the master branch. We don’t build it in the develop branch.

If you search for the new features in master branch… We have not merged it yet. The phar file is not up to date.
Please use the develop branch to test the new features.

Categories
Magerun

MageRun Addons by Peter Jaap Blaakmeer

This article is part of a series covering 3rd party n98-magerun modules/extensions.

In this post we cover a 3rd party n98-magerun module created by Peter Jaap Blaakmeer which adds some new commands to your list.

Categories
Magerun

Released n98-magerun Version 1.93.0

n98-magerun_1_93_0

The year is nearing its end fast and we have bundled a new n98-magerun release for you. The version contains some new commands, enhancements (listed at the end of the post) and updated Symfony components to 2.6.

New Features

Unlock Admin User

Any user of the Enterprise Edition had this. If have enabled automatic user locking you must wait some time
if user will be unlocked.
Now you can unlock any user with the new admin:user:unlock command.

  • #399 Admin user unlock [EE only] (by Steve Robbins)

Clean multiple caches at once

It’s now possible to pass more than once cache identifier to the cache:clean command.

  • #415 Clean multiple caches at once (by Michael Barrett)

Better Cache Handling

Alan Storm optimized the cache initialization. I some cases we recreated the already initialized cache. This is now fixed.

  • #418 Use already instantiated cache object. (by Alan Storm)

Enable/Disable Module (by definitions)

Enable or disable a module in app/etc/modules/*.xml by name or codePool:

Examples with codepool option:

Please not that the codepool option affects ALL modules of the codepool.

  • #421 enable or disable a module based on name or codepool (by Steve Robbins)

DB-Status / Variables

Cyrill Schumacher added two new command to the db namespace.

db:variables -> Print all important MySQL variables

db_variables

db:status -> Print status informations like the current used InnoDB Buffer Pool hit rate.

db_status

  • #435 New db:status and db:variable commands (by Cyrill Schumacher)

Refactored bash completion script

On some platforms the current version of the bash complection script is not working. Johannes Klein provided a refactored bash completion script which contains a workaround for some problematic PHP versions.
We got also a patch by Paweł Bogut which is not needed anymore because we can provide a command list which is parsable without a regex.

Other Improvements

  • Minor documentation corrections (by Jaik Dean)
  • Refactored db:maintain:check-tables to allow InnoDB and Memory tables to be optimized. (by Cyrill Schumacher)
  • Bash completion – change regexp condition to string contains. (by Paweł Bogut)
  • Updated Symfony components to V2.6
  • Updated locked phpunit version.
  • #423 db:import –drop does not take into account the “only-command” option (by Michael Lühr)
  • #429 Install command ignores skin folder of 1.9.0.0 sample data (by Vinai Kopp)
  • #436 Alternative Installation Port is not respected (by Christian Münch)
  • #440 Added Magento CE 1.9.1.0 to installer (by Rouven Rieker)