I'm a 12 year experienced PHP Developer. Today I discovered that I don't know how to write PHP
I applied to a PHP job and the interviewer sent me a test as following:
"Write a CRUD application connecting to PostgreSQL, but please don't use full-stack frameworks like Laravel, Symfony or Code Igniter, also don't use Apache or Nginx, just use the built-in PHP server and PostgreSQL, that's it".
Well, seems to be simple, right.
This test is not for a Junior position, it's supposed to be a Senior PHP evaluation, so they are expecting that I will deliver some modern PHP code. I can't just sit down and write some 2005 like PHP script full of includes and procedural.
Before I even think about the CRUD itself, I need to think about folder architecture; a bootstrap/front-controller; a routing component; some kind of basic template system to display standard HTML views; something that at least resembles a ORM or a well organized Data Layer; not to mention basic validations, helpers and of course, unit tests.
I'm kinda lost and the impostor syndrome hit me very hard on this one.
Seems like before attempt to any job interview I'm gonna need to start learning PHP from scratch.
EDIT:
From today on, I decided to call myself a "PHP Framework Driven Developer". I'm definitely not a "Flat PHP Developer", and I'm totally OK with that. Things will be more clear when accept or decline job offers.
Thank you all very much for all the wise words and feedback!
11
u/midniteslayr Dec 23 '20
As a Senior dev, who has been using PHP since 1997, I can safely say that this test is BS and not worth the time to put in to it. It wants to test Technical knowledge, but that is something only reserved for mid-level engineers. Senior devs should be asked architectural type questions, as most of the time, you have to consider systems and the impact of those systems on the code base and other systems. This interview sounds like it is for a team that is staffed with a Lead Developer who doesn’t like to delegate, and is intentionally trying to weed out good and bad talent with the stupid requirements, only leaving somewhat mediocre talent who are easily abused by the lead, paid below average, and are only in the job to add a “Senior” title to their resume.
If I were you OP, I would decline and look elsewhere. Your time is too valuable to spend worrying about the test, that will more than likely result in them passing on you (because you’re too talented) or insult you with a really low pay wage.
2
u/DreadCoder Dec 24 '20
I have found throughout the years that the software tests you are given ALWAYS reflects company culture.
You dodged a bullet here.
This is the kind of test you would give to a junior/medior position. Either they have NO IDEA how to assess people (which will come back to haunt you when anything regarding compensation is involved) or their priorities are DISTURBINGLY misaligned.
2
u/lexi_berkman Dec 24 '20
My idiot brain just read, “12-year-old, experienced PHP developer” as the title. I was freaking out for a sec.
233
u/adragons Dec 23 '20 edited Dec 23 '20
You don't need orm/data layer/templating. You're over thinking it. Put the SQL in the models.
For routing just use a big switch statement and GET parameters.
Use php as the templating system.
An interview test like this isn't "show us you can implement the best system" it's a "show us you can write php". Adding things like an ORM are a discussion topic for how you would improve it.
66
u/[deleted] Dec 23 '20
Not to make you feel too good about yourself, but the fact that you can list out p much all the considerations you’ll need means you’re probably not an imposter.
the fact that you can’t barf a crud app without googling a little means you haven’t been doing speed coding competitions lately.
28
u/Salamok Dec 23 '20 edited Dec 23 '20
I'd probably use a simple templating class, rough in some common codebase (bootstrap/global functions/config) and a simple front-controller, skip the pretty url router, caching and more complex stuff (but think about how you might approach those). I think you are over thinking it, they dont want a production quality application they just want to see some code. When you do the walk through touch on how you might improve the application if given more time (add routing, caching, etc...).
Remember they just asked you to write an application that adds, updates and deletes records in a database. They didn't ask you to come up with a full featured framework. Keep the code clean and simple, be sure to use PDO and not have any glaring security flaws in your SQL. Keep in mind they may red flag too much procedural code so steer things in an OOP direction.
edit - To each their own but I far prefer interviews where they give me a few days to write something that becomes the MAIN discussion topic of the in person interview. I always walk into these interviews prepared because hey we are gonna talk about "my code" and "my approach" this is infinitely better than being hit with a barrage of brain teasers that seem to exist only to prove how clever the interviewer is.
11
u/jitendracshah Dec 23 '20
I am on opposite side, I use it starting from 2010,can work on modern vanilla PHP, But I cannot get myself deep in frameworks, I kinda not like that too much abstractions.
and I just accepted it, when I need to use framework I just Google it and make short term memory of it and later forget all.
13
u/Tiquortoo Dec 23 '20
Is that the complete spec? In that case you need none of that. I read these requirements as "Write a simple app, not a modern one, do it barebones." They didn't ask for folder architecture, bootstraps, routing, templates, views, controllers or anything. They kicked the crutch out from under you and said "Dance!" So... just do it.
It might just be that the first test of this test is: Does the person have a habit of inventing, or not asking for refinement of, requirements. Which is a pretty key skill for a Sr. dev.
7
u/missitnoonan78 Dec 23 '20
Why? What exactly is this testing and why is it practical knowledge in 2020? This is the type of nonsensical busy work that drives me crazy in an interview.
12
u/colshrapnel Dec 24 '20 edited Dec 24 '20
Yes, you need to learn how all these things work. Actually basic versions are no more than a dozen lines of code:
PSR-4 autoloader is even less
switch casegiven you are using GET parameters or if you want to make it a bit fancy, then use the router parameter for the built-in web-server which will redirect all requests to your router file where some basic string parsing is involved and then the same switch case.basic templater again is half a dozen lines,
For the CRUD itself you can choose between two approaches: it could be a blunt one-entity CRUD where you are writing direct SQL; or you can create a basic abstract ORM, or a TableGateway, like this
and then just bang in the Create, Delete and List
Then it can be used like
you see, it's not much a code to write
54
u/Fit4BJJ_Pat Dec 23 '20
That doesn't sound that hard to me? A senior should be able to handle it.
You don't need an ORM. You don't need a template system, PHP has one built in already. They are not asking you to write production code, just to see if you can handle writing code without a framework.
If you are completely lost without a framework then maybe you should not call yourself a senior PHP developer. Maybe a senior X framework dev, but not PHP.
Maybe this will helps (although it uses components): https://github.com/PatrickLouys/no-framework-tutorial
21
u/systemadvisory Dec 23 '20 edited Dec 23 '20
Just use include to include php files, use inline php for templating. Use PDO for db queries. Use GET paramater 'a' or something to show what action to use. Don't over-engineer it, it seems like they wouldn't like that. Here's a model I would start with:
https://pastebin.com/r6zhGC9h
21
u/kingdomcome50 Dec 23 '20
I’m going to be honest. I had that entire project written in my head within seconds of reading the prompt. This is exactly the kind of question I would ask to weed out people who don’t know how to solve problems.
The above shows that you know how to program, and that you know how to organize a system without leaning on a crutch like a modern framework to handle all of the details. This is really important because none interesting problems out there come with a framework in how to solve them. Believe it or not, most business problems aren’t “make a small CRUD app” and sometimes require some actual engineering to solve them.
It sounds harsh (and I expect some backlash), but maybe you aren’t a senior developer. Years don’t necessarily equate to aptitude. I saw this quote on HN the other day and I think it would help give you some food for thought:
Write code. Not too much. Mostly functions.
5
u/hktr92 Dec 26 '20
This is a paradox I've encountered too. We are so used to work with frameworks that when we have to use vanilla PHP, we either reinvent a framework (like I did with a uni project) or bang our heads against the wall that we don't know vanilla php.
same feeling I had when I did that uni project. I ended up writing a minimalist PHP framework that did the routing automatically for me depending on request method. Yes, I'm a lazy person and I'm not ashamed to recognize this one. and when a colleague of mine (which don't know anything about PHP, while I'm working for 3 years as a web dev) asked me if this is really necessary I simply replied "meh, it's easier for me to do certain tasks this way, it prevents me to have duplicate code and have direct access of variables".
sure, I could do something like `request_get('name')` where "name" is the param name from $_GET, but meh, having a full-blown `Request` class with stacks felt more natural to me.
and this is somehow weird, because this uni project made me feel like I don't know PHP at all. and the consequence is the usage of PHP frameworks. but the biggest advantage we have is that when we have to write something "from scratch" we already know how to structure and do better this one, creating some sort of "framework" or "app logic" (if you want to name it like this, it's irrelevant the naming) that our app would be developed easier and faster without banging our heads against the wall that we don't know what method x does in framework / library y.
on the other hand, at work, we employed a very talented guy that worked with vanilla php and built-in php framework before. our project was already started with symfony and he found it weird and he "was afraid of symfony" (his exact words). now he's more confident in that framework but he still does have a small fear of the framework, on the principle "i don't want to break it". however, his background helped our project so much that even I changed my vision and coding style in symfony and in php projects in general.
the conclusion is, when you develop php project in frameworks, you forget what php really can do. on the other hand, if you don't use frameworks at all, you are a bit reluctant to use any framework at all as it limits your skills and you tend to do many things to achieve little. so having a balanced experience both vanilla php and a framework would be ideal, but it won't be as easy as one might think it would be. (since I started to work on various php projects, I did something like "for each php project that used a framework, wrote a php framework myself that simplified some of the things a framework did, afterwards learned a framework in other programming language to achieve new knowledge and better understand php".
2
u/phdaemon Dec 23 '20
You could always use a microframework for the MVC part. However, saying don't use frameworks to me is a red flag.
4
u/ahmadalmayahi Dec 23 '20
It shouldn’t be that hard. Here are my suggestions:
filter_inputfunction./srcand tests in/testsfolders.spl_autoload_registerinstead of composer autoloading.pagequery param and invoke the appropriate function/controller.1
u/S44F4Y4T Dec 24 '20
Btw what is built in php server?i thought it only run on server either apache or nginx
1
u/secretvrdev Dec 23 '20
If your problem is the folder structure youre out. Just stop.... omg why do you call yourself a senior if your have problems with folders.... omg
3
u/brzzzah Dec 23 '20
Is there any reason you can’t use existing packages to compose your own framework? The way I interpret that require its still open to using packages, that’s what I would do. for example I might use php-di, fast-route, (maybe even slim?) cycle or doctrine for data layer, twig for views etc. you can whip up a nice modern app like this quite quickly
3
u/BoneBreakerz Dec 23 '20
Having been on both sides of this exact same question, I can tell you that you are definitely overthinking it by a long shot. The most complex piece here is the C in CRUD, it needs authenticate, and make a connection, so keep security in mind. Then the rest of the functions should take your persistant conn as a parameter, along with the query params, and basically just execute. Keep the functions basic, simple, and to the point, and you will get bonus if you remember to sanitize your queries to prevent injections/xss/etc. That's all they want to see, don't fret about routing, bootstrap, or HTML, they want to see your PHP code and that's it.
Senior Dev's aren't about who can write the most convoluted, abstracted, now only GOD knows how this works code, it's about who can write code that everyone can understand, meets the criteria, and doesn't break when you toss "lizard" as an integer.
3
u/sleemanj Dec 24 '20
I'm a 20 year experienced PHP developer, I feel the exact opposite of you.
If given that task I would be in heaven, simple, easy, straight forward, no problem piece of cake.
But ask me to do anything in any of the current frameworks and I feel like a steam engineer dropped into the space program.
3
u/Herbert256 Jan 02 '21
that's still how I use PHP, as a template language without using frameworks or template engines.
PHP did go into the wrong direction, it started when OOP was added, it gets worse every release, 8 is complete nuts.
5
u/stilloriginal Dec 23 '20
Not a pro or anything but you could simply use a repository pattern and write the queries inside that.
1
u/helpfuldan Dec 24 '20
Yeah it does seem simple. A quote CRUD application. Create new quotes for database, read quotes in DB, edit quotes in DB, deleted quotes from DB. Default page displays all quotes. Edit button changes it to a textbox that you can save changes. Form to add new ones. Delete button. One php file, like 40 lines for the entire thing?
2
u/bad-donkey Dec 23 '20
Maybe I'm being a bit naive but it sounds like you can write this like an API. You can use AJAX to hit the different CRUD endpoints. You're folder structure could be something like:
Products Read.php Create.php Update.php Delete.php Objects Products.php
In this example the endpoint would be Products/Read.php and that file would be in charge of headers and grabbing any data passed in and validating. Objects/Products.php would be an instance of the object and you can set it up to have a DB conn as the constructor that is passed in whenever it is called by one of the CRUD endpoints. I dont know if that's what they're looking for or if I am just being super naive.
Sorry for the format I'm on mobile.
2
u/dontc9 Dec 23 '20
It's weird that you post the solution. Probably they want you create a framework or extend functionalities of an existing framework.
2
u/detonator13 Dec 24 '20
Has anyone considered all the other things they would be looking for? As a hiring manager, I want to see if you used git, composer, unit tests, covered security, etc. I want you to be able to talk through your choices. For a senior, I want them to ask questions. I want them to challenge me. I want them to tell me that my rules suck and if they can work outside the box a bit, they can do it in half the time and it’ll be more maintainable. Also, lastly, the choice to ask not use a framework is likely in large part due to having to sift through all the boilerplate to review later instead of just having a couple files to look at.
That said, it could just be a shit company and/or bad interviewer. Never know.
2
u/Envrin Dec 24 '20
Hell, if you don't feel like the job, feel free to send it my way. That type of test sounds right up my alley.
2
u/styphon Dec 24 '20
I'd go back to them and ask what they are looking for and why they want you to write everything from scratch instead of using commonly available open source tools. This test doesn't make sense to me, if you have to write everything you're thinking of then it's crazy.
Now bear in mind I've only got the quote you gave above to go on but it sounds like you're overcomplicating things. In my opinion (and experience as a lead developer) they only want something simple. Yes, they want something modern and utilising OOP, but it doesn't have to be massively complicated. They just want to see you can do what you claim.
Forget the ORM, forget any MVC model, it doesn't need that. No, you can't use procedural code with lots of includes but adding in an autoloader with composer should be trivial for any senior dev (if it's not for you, google it, it's not hard and won't take you long) and so using OOP with that isn't out of the question for an interview test.
Show them exactly what they asked for, a simple CRUD application that connects to a PostgreSQL database using PDO. The PostgreSQL website has some good tutorials and will give you an idea of what your code should look like (but don't be an idiot and just copy/paste it).
2
u/DaveInDigital Dec 24 '20
as a senior who regularly interviews developers, i often ask interviewees to figure out small problems through vanilla PHP not to see how much they know but how they look to solve them. do they ask questions? clarify instructions? pull up documentation? see how others have solved similar problems? i don't need a human encyclopedia, just someone that can efficiently work through problems and who knows how to ask questions when they're stuck or unclear. code is just a vehicle to that. it's assumed from the get-go that your vanilla PHP is going to be rusty, or your PHP altogether when you're away from it for any period of time as you work in other languages. i love when developers immediately pull up PHP docs; everyone should use them at work in real life projects anyway.
also a lot of code out there is still super legacy. it's often not feasible to just rebuild everything with Laravel overnight; more often than not business needs have to be considered (that's how you get paid) and sometimes old projects just need to be maintained or lightly refactored because there's little to gain in a rewrite. a senior developer should have the experience to weigh all these things. often we have experience in our early years going full bore on a refactor and end up causing more bugs and confusion 🤪
in your task, i would write a very simple PDO-based app and include comments along the way explaining my reasoning, what i would do different in a production application, etc. it may or may not be what they're looking for here (this is where asking questions is good, something a senior needs to do often when putting together a project in the planning phase) but if you're true to yourself as a developer, you'll find the right employee-employer match eventually which is a lot more rewarding anyways.
i often thought i was the imposter in the room until i realized almost every developer i respected felt that way too. if anything it just means we realize we don't know what we don't know and that's healthy, keeps you curious and always working to get better.
2
u/[deleted] Dec 24 '20
The biggest issue with frameworks is that there is too much magic, and their tutorials/examples teach you to write code that is tightly integrated and mixed with the framework (symfony and laravel both do that a lot).
On the other hand, Php from scratch is a terrible idea too.
All you need is to understand what a modern framework does for you. There is a very nice Symfony series of articles showing you how to build your own framework using libraries.
https://symfony.com/doc/current/create_framework/index.html
TBH, this should be standard reading for everyone starting on php today.
The second thing that you need, is to learn how to write code that is framework independent. This means that you should be able to move your code from framework to framework to no-framework with just minimal framework-specific glue code.
All big frameworks are guilty of pushing you to let the framework do much of the work that should be done in your business domain code. Or pushing you to mix repository actions with controller or template or business domain actions.
All that on a theoretical level though. In everyday life, you have to do things fast, so you do what you have to and move on.
Now for your exercise, if you can use composer and pull libraries, then half of your problem is solved. You only have to demonstrate that you understand how modern php frameworks work.
7
u/helloworder Dec 23 '20
I would just drop the task and never reply to them. Why waste so much time for this? There are plenty of other jobs to apply.
3
u/JaggerPaw Dec 23 '20
Is this a Web CRUD application or just an application? The web introduces the routing, front-controller stuff, views. Not sure why you need an ORM or "data layer". You are writing CRUD for what? one table?
Autoloading, unit tests, and helpers (which is where validation functions usually live) are all going to be needed. I implement helpers as needed, so as not to over-engineer. If you have a functional function (or series of statements that can be converted), used in some object - make something like a <namespace>/lib/helpers/<object>Helper.php class and stick it in there. Makes it a lot easier to test code now.
3
u/pragmageek Dec 23 '20
They didn't say anything about not using composer.... pick some packages and away you go.
3
u/Xpertbot Dec 23 '20
Includes? Procedural? PHP has come a long way man.... the only include you should have is inside index.Php in your public folder for the bootstrap.Php file that has the auto loading then everything else can go in classes. Architecture wise, MVC is battle tested and it will work. You can create a connection using PDO. PHP IS a view templating system just make sure you include the templates inside a function in a Renderer class so you don’t pollute the global scope with your variables
4
u/sergb39 Dec 23 '20
I may see a point in this task like "see if you can manage without framework and know how to build it by yourself" but why? This is not something you can do in couple of hours and it is huge waste of time.
I really against those kind of interviews where they ask you to do something stupid that you will never do in real life.
3
u/[deleted] Dec 23 '20
The kind of test says a lot about the company. If they would ask me to do this I would politely wish them a nice day and walk away, you don't want to work at a company that don't let you use a framework.
2
u/jstnryan Dec 23 '20
I would have used that as an excuse to build the most incredible single-file, single procedure, IF statement infested, mysql_query awesomeness to ever awesome.
2
u/Chesterakos Dec 23 '20
The only reasoning behind their interview exercise is that they have something on-premises that resembles that monstrosity they asked you about.
I'd really ask myself if I really wanted to work there with that in mind.
1
u/umlcat Dec 23 '20
You're used to use a lot of stuff !!!
Keep it simple.
1
u/crackanape Dec 23 '20
Sounds like you've decided you don't want to reply to their coding test as posed. That's up to you.
1
u/32gbsd Dec 23 '20
No hard feelings there are lots of php cargo cult shops who need people like you to help finish their modern php projects. Dont worry about it.
1
u/[deleted] Dec 23 '20
This seems a bit much for a job interview, especially if they're not going to pay for your time spent. I had to do something similar for a different job and the company turned out to be a complete shit show. Writing great code like you mentioned would probably take multiple days, since you're basically writing an entire framework from scratch. I get having programming questions as part of an interview test, but it needs to be scoped down to 1.5 hours at most.
1
u/Kaishiyoku Dec 23 '20
You don't really need anything of that. An autoloader, yes. But everything else? Debatable.
1
u/MorphineAdministered Dec 23 '20
I guess they're looking for specific kind of senior. With such a discrepancy in problem awareness I can foresee your end there with death by a thousand cuts. Wouldn't apply.
1
u/jackistheonebox Dec 23 '20
Don't worry this is how interviews sometimes feel. Don't overthink this as you will get stuck on details.
1
u/[deleted] Dec 23 '20
Once in a while, it's good to revisit/maintain you old 'custom' code that you wrote for a personal project.
1
u/pikknz Dec 23 '20
They only expect 2-3 hours work so just make it work minimally. They mostly want you to do the code securely in queries, i.e. prepared statements.
1
u/illathon Dec 24 '20
Seems kind of excessive for a test application. Is this normal?
1
u/psion1369 Dec 24 '20
The specs don't include much on the way of templating or too much on routing. Just build something that spits out the output after taking in the input on a server param. I wouldn't even consider the routing as it could just be called in the old fashioned way of the direct file. Don't overthink and include what isn't necessary.
1
u/Large-Meat-Feast Dec 24 '20
looking at it from the other end....
Single php class with each method as a static
second php class for DB connection
php page/form that calls the method.
boom!
1
u/[deleted] Dec 24 '20
A very STUPID APPROACH from interviewer.
1
u/[deleted] Dec 24 '20
I don't bother with these tests any more after the last place asked me to build something then ghosted me. Plus I rather do anything other than write code that I know will be thrown away. I have plenty of open source code available for review.
If it's just a short exercise (which this appears to not be) or If I had no job then that would change things of course. Where do these places get off?
1
u/c0ldfusi0n Dec 24 '20
Now you know what is wrong with developers nowadays who depend on frameworks that abstract the knowledge they actually need.
1
u/[deleted] Dec 24 '20
Well
is always a good thing to know.
These types of interviews suck. So the MVP of this isn't that hard tho but, still, you are looking at 1 - 3 hours of work. On top of that: will you be penalized for skimping on testing, error validation, the technique of 'just getting it done'. I can hear feedback like well you used POSTs for updates and didn't use PUTs or DELETES
If you don't need this job push back. If anything you can make them question their interviewing process.
1
u/SavishSalacious Dec 24 '20
That’s not what they’re looking for at all.
They don’t want you to build a framework, they want you to make a CRUD app in RAW php. Why?
I wonder why, what kind of applications are they building? What’s their architecture like? Are they using frameworks? If not this could be scary old school spaghetti code.
If they are using frameworks, they just want to know that you actually know php, and that you don’t just depend on frameworks.
In other words:
Keep It Simple Stupid.
1
u/LordSpaceMammoth Dec 24 '20
Is it a closed book/offline test? There are a lot of results for "postgresql built in php server crud generator" -- you could have one ready to show pretty easily. I mean assuming they are ok with some amount of non-original code; that the exercise is to see if you can get some php written.
1
u/mangelsnc Dec 24 '20
Just chill and analyse: you can use Composer for autoloading, and this is one of the hardest parts of your problem. You can use built-in PDO classes for DBAL, build a super-simple dependency container is like implement a big array... the rest is just the same.
Think out if the box, you don’t need a hyper complex framework to just pass the test.
You can do it for sure
1
u/secretvrdev Dec 24 '20
People in this thread: "I dont do that because i need 10 days for a simple crud app in my standards"
Company: "Go away with your standards that cost to much"
People: D: I AM ANGRY
1
u/baohx2000 Dec 24 '20
Just because you can't use a framework doesn't mean you need to reinvent the wheel. All of the actual components to build a framework (DI, Router, Middleware/Dispatcher, DBAL) all exist. Just search packagist. You just need a bit of glue code to build a micro-framework.
1
u/Deji69 Dec 24 '20
It says not to use a full stack framework, but you can surely use smaller frameworks and libraries. Otherwise they're basically asking you to just whip up your own full stack framework.
1
u/Beerbelly22 Dec 24 '20
I love this. I have often the opposite. Not much experience with frameworks as i often can write the code myself faster then learning another new framework. I feel they have a new framework every week.
1
u/c_eliacheff Dec 24 '20
Not an expert but here's what I would like to see from any dev:
1
u/awardsurfer Dec 24 '20 edited Dec 24 '20
you would start with composer. They say “don’t use a framework”, but doesn’t mean “no php libraries”.
So you’d new-up a composer file and start requiring basic packages. Then write your code.
Personally I would pass. it means jack weather I remember PDO or not. It’s like the stupid tests with bitwise questions. Who gives a fuck. Nothing you’ll ever use.
Frankly, I think once you reach senior experience, just go get your own clients and/or contract with agencies. Do your own shyt, make the $$$.
1
u/bensor74 Dec 24 '20
They just want to see if you know how to use PHP outside of a framework. Use composer packages and you'll be just fine.
1
u/2020-2050_SHTF Dec 26 '20
I had this one before, except it was for a junior position, I think :D
The thing about not using a web server is just so you don't write anything in a config file like .htaccess, that might do some rerouting.
For the db, I used someone's singleton class from GitHub, which I mentioned of course.
Then I used composer for namespacing stuff and just wrote some classes that were then called via scripts referencing the crud calls.
At least that's what I remember doing. I got an interview, but not a job from it. They did say it was the reason I got the interview though.
1
u/welterwerk Dec 26 '20
You can still use packages via composer, right? If so, it is not a big deal to accomplish that task. There are a lot of great packages which resolve most common issues – like routing, database connection, templating system. You just need to gather them up and use.
1
u/breich Dec 28 '20
I think if it were me I'd ask for some clarification. It sounds like your head immediately started thinking about "what framework components do I need to build the solution in a flexible, forward-thinking way?" So did they want you to build the framework to solve the problem, or solve the problem in plain PHP? I suspect the latter.
1
u/zvive Dec 28 '20
I was given a similar thing, but was told to use a specific routing package.... so I basically made my own laravel clone(ish), using the router, propel for migrations, etc... it said not to use a framework, but you can still use packages I presume? If so, just use some packages to get you half way there, it's still easier than not using a framework and not using any packages.
1
u/Jurigag Dec 30 '20
In today days you use API in 90% cases
Don't need it so much to simple CRUD application, DBAL will be enough
You can do validation on __construct of classes and simply throw exception.
1
u/ltsochev Jan 04 '21
So, using PDO is too hard now and writing a model with built-in SQL is a no-go nowadays? I don't know man. I've been working with PHP for over 10 years. If I have to go to an interview or some certification test and they ask me to do A I'll fucking do A in the shortest amount of time possible. If they want me to create something actually useful, they'll need to pay me.
Bonus points for using PDO ... prepared statements - bye bye sql injections.
Back in the day ... before frameworks, all that we did when we started a new project was to re-invent the god damn wheel and write a new but slightly different database wrapper class :D Should work splendidly at an interview. For more, like I said, they'll have to pay me.
1
u/x_mk6 Dec 24 '20
Bro you're 12 how experienced could you possibly be lol
1
u/[deleted] Dec 23 '20
It might be one of those projects that isn't supposed to be perfect, but allows them to see into how you think
'php -S localhost:80' to start the dev server if you don't know
Throw in a docker postgres instance, easy. Id personally wrap it into a docker-compose so they can easily type 'docker-compose up'
Document well, add good test coverage
For the db layer, id make a repository/dao object per entity and use heredoc to write nice queries. Use pdo with bound params.
For models, id define the private props and make getters and setters. Check out jms serializer to write to json
1
u/geggleto Dec 23 '20
my advise would be to run away, far away
0
u/BONF1RE Dec 24 '20
Y’all realize this is satire, right?
0
u/SmotherMeWithArmpits Dec 23 '20
Sounds pretty fair besides the not using apache/nginx part, tell that guy to go smoke some more crack
-4
u/[deleted] Dec 23 '20
LOL that is ridiculous. I would definitely use some libs & composer, not gonna write all that if they want to see good code quickly
0
u/guice666 Dec 23 '20
I used to give tests regarding the language itself, little "gotchas" you'd only hit when using PHP directly. For example, using an
if (strpos())- asking them what will happen and why.0
u/wavewakerz Dec 24 '20
Me for my part hate working with frameworks. To much overhead and performance drop. Better write everything yourself in a way you need it. Whenever I was in companies using big frameworks like laravel or symfony we always ended up migrating to a selfmade system.