BFS | 49ms | 100% Beats | PHP
Code

# Code
```php []
class Solution {

    /**
     * @param String[][] $maze
     * @param Integer[] $entrance
     * @return Integer
     */
    function nearestExit($maze, $entrance) {
        $rows = count($maze);
        $cols = count($maze[0]);
        $directions = [[0, 1], [1, 0], [0, -1], [-1, 0]];
        
        $queue = new SplQueue();
        $queue->enqueue([$entrance[0], $entrance[1], 0]); // [row, col, steps]
        $maze[$entrance[0]][$entrance[1]] = '+'; // Mark the entrance as visited
        
        while (!$queue->isEmpty()) {
            [$row, $col, $steps] = $queue->dequeue();
            
            foreach ($directions as $direction) {
                $newRow = $row + $direction[0];
                $newCol = $col + $direction[1];
                
                // Check if the new cell is within bounds and is an empty cell
                if ($newRow >= 0 && $newRow < $rows && $newCol >= 0 && $newCol < $cols && $maze[$newRow][$newCol] === '.') {
                    // Check if the new cell is an exit
                    if ($newRow == 0 || $newRow == $rows - 1 || $newCol == 0 || $newCol == $cols - 1) {
                        return $steps + 1;
                    }
                    
                    // Mark the cell as visited and add it to the queue
                    $maze[$newRow][$newCol] = '+';
                    $queue->enqueue([$newRow, $newCol, $steps + 1]);
                }
            }
        }
        
        return -1; // No exit found
    }
}
```
['PHP']