Getting QGIS 2.x python code to work in QGIS 3.x? object has no attribute 'legendInterface' problem
You could just replace:
layers = iface.legendInterface().layers()
with
layers = [layer for layer in QgsProject.instance().mapLayers().values()]
The equivalent of
layers = self.iface.legendInterface().layers()
in QGIS 3.0 is
layers = [tree_layer.layer() for tree_layer in QgsProject.instance().layerTreeRoot().findLayers()]
This recursively finds all layers and returns them in the same order as listed in Layers Panel.
I found this to list layers:
layers = qgis.core.QgsProject.instance().layerTreeRoot().layerOrder()