atanasg's avatar

Creating new projects with Lumen for novices is a pain in a few rather tender places.

"Get started with Lumen" guide for novices or at least a "Quirks report" will be appreciated. Lumen looks great on the outside but it seems strangely feeble once you try it. Below are some fragments of what I experienced this weekend. I am new to PHP and new to Lumen (so far 3 days on both). Environment: Macbook Pro, El Capiten, PHPStrom11EAP, Lumen (Installed 1.0.1).

A. If the PHP unit is not installed (properly) entire vendor folder comes up empty w/o any suggestion as to why. Later even after PHPUnit is installed and added to the project, the paths to tests are not properly auto configured leading to messages like: Class "PHPUnit_Extensions_RepeatedTest" does not extend PHPUnit_Framework_TestCase.

B. Missing or broken test workspaces Monolog; Doctrine/Tests; FastRouter/Dispatcher are missing from autoload_namespaces.php. I had to study the whole test case concept before I created them there. FastRouter/Dispatcher does not have the proper folder structure (FastRoute folder is missing). I had to create it inside vendor/nikic

C. Unsafe code inside the RoutesRequests.php When you attempt to debug via PHPStorm11EAP IDE the the $_SERVER doesn't have REQUEST_METHOD and REQUEST_URI which causes crash at getMethod and getPathInfo. I was forced to change the code in the very framework to make it safer and allow debugging. Example: from: return $_SERVER['REQUEST_METHOD'] to: return isset($_SERVER['REQUEST_METHOD'])? $_SERVER['REQUEST_METHOD']: 'GET';

The only good part so far: It forced me to learn the whole frkn framework in 3 days. And laracasts ROCKS.

0 likes
10 replies
jimmck's avatar

You are 3 days old in PHP and trying Lumen? Do you have a background in Web coding in JAVA or ASP? You don't need PHP Unit. Did you install composer? Can you type php -v and get a version? No one can help you with the kind of information you posted. With a proper PHP install and Composer install, Lumen installs just fine.

jlrdw's avatar

Well I was going to do a small site with lumen, couldn't even get a welcome screen, I stuck with laravel. I can get a new laravel welcome screen right after composer is finished.

jekinney's avatar

Lumen is defiantly a bit more advanced the Laravel. Many does not have any scaffolding to get you going.

Keep in mind lumen is a micro framework and though others like swift (even harder to set up btw) are advertised as usable for web sites, lumen really isn't imo. More of a service feature like for small APIs or running as a cache or some service that would consume an applications resources that slows down the main app.

My use case for lumen has been as a cache, generate very resource heavy reports and as a cron use running commands and db clean up.

Just to use it as an API with eloquent etc takes twice as long for initial set up then Laravel.

atanasg's avatar

First of all, I am amazed how live this forum is. Replies coming 15 min after posting. Wow... @jimmck: I "decided" to learn a web language this weekend :) however, I was rather experienced in software development before I started to crawl up the ladder. Last serious code I wrote was 2009 but before that very solid 12 years. Assembly 386, Lisp (scheme), C++,C#, Pascal (Delfi), Java, Java script ... etc are just the languages I used in big projects. Yes, I am rusty but not hopeless.

@jekinney: Needed to pick a language for fast prototyping. The complete Laravel seemed overkill. As I am equally inexperienced in ruby, python and php. PHP selection and Laravel in particular was mostly emotional (after 1 day research and comparison). At my age and with my past experience I am sure I can pick any language in less than a week and get good at it in about a month.

I need to quickly create new projects that start from the first second (not after 2 hours of adding namespaces and changing configuration). Your advise will be much appreciated.

ENVIRONMENT (all installed last Saturday): composer -V : version 1.0-dev lumen -V: Lumen Installer version 1.0.1 laravel -V: Laravel Installer version 1.3.1 php -v: PHP 5.5.30 (cli) (built: Oct 23 2015 17:21:45) localhost/phpinfo.php: PHP 7.04 PHPStorm11EAP: interpreter configured to use 7.04

I thought from my prior post it is evident that I plowed trough and was able to eventually complete a debuting session form the IDE and remotely (form a browser). However, It was not trivial. Problem C is not configuration related. Problem B is am suppose a composer issue. I am not sure how to categorize problem A.

Again, I used Laravel documentation and tried to extrapolate it for Lumen and today is my third day on the language so please bear with me.

willvincent's avatar

@atanasg Out of the box, lumen is really intended for building an API, so service endpoints rather than displaying a full HTML page. Unless you're using something else on the frontend (angular, ember, react, etc) and lumen simply to manage data persistence on the backend, you'll probably have an easier time getting up to speed and rapid prototyping with laravel than with lumen.

jlrdw's avatar

Well right on the home page of Lumen there is this code snipplet:

<?php

$app->get('user/{id}', function($id) {
    return User::findOrFail($id);
});

That doesn't look like an api example, it looks no different that a laravel piece of code.

atanasg's avatar

@willvincent: Point taken. I may reconsider. Of course I prefer to do it because of sane arguments (like yours and jekinney's) rather than from frustration. I planned on using dhtmlx library. I did not mention it in prior posts as it did not contribute to my frustration form last weekend. The "plan" I set for myself was:

  1. Understand PHP and Lumen/Larvel
  2. Understand resource management (gulp, elixir ... etc)
  3. Understand composer and modify composer configuration to automatically install all js libraries and the standard layouts I need
  4. Do cool stuff...

My frustration came not from the fact I have to write few hundred lines of php, js or html but from the rather stupid problems I was fighting. See, Instead of learning the Laravel object model I was debugging frkn RoutesRequest.php and asking myself what kind intern will request an array element without checking if it is there on first place and then have no exit strategy at all. See getMethod and and getPathInfo implementation, and I am sure you will agree.

jekinney's avatar

Routes in Laravel took my the longest for some reason to get my head around too. Maybe the syntax or something I don't know. I can from asp so mvc part was fine. Those dang routes though.

Even if full blown Laravel is over kill, seriously give it a try for a bit. After awhile move over to lumen if you need to.

With Laravel: install, edit env, run key:generate, start server and your off in 5 minutes. Ready for viewing and coding.

@jlrdw that code snippet returns Json not a view btw. Ie: API.

atanasg's avatar

Saw the light eventually. Followed your advise, switched to Laravel. Works.

Please or to participate in this conversation.