Skip to content

u/captbrogers

In this archive from Dec 2014 to Jun 2015

0
posts
45
comments
0
media
81
score

I'll throw this out there but I'm sure I'll get some heat from others about it: I prefer Fedora Server over CentOS or Ubuntu.

I've managed all three, and CentOS/Ubuntu absolutely are better at being able to "set and forget" with minimal active administration. The reason I like Fedora is because I can get the more up-to-date packages without extra repos. If there are ones that have licensing conflicts with Red Hat, then there's RPM Fusion. I also really dig Cockpit, but I haven't really used it for anything other than playing around.

My reasons are entirely personal, but all the same I prefer Fedora.

1 points

I personally prefer the config usage the way it is, just easier for me to connect in my head. That is only a personal opinion, but I can see why others may want to use the option you've shown.

That said, have you changed that in a project and done benchmarks on it to test the speed? I'm curious what kind of a performance impact that one change could make.

1 points

There are two options that come to mind, though I haven't tried either but they are on a todo list for me. So this may not work, but just my off-hand ideas on the subject.

Use some form of sockets, either with Ratchet or something built with Socket.io. When a page is loaded, you have a JS file that connects them to the socket service and that handles pushing the notifications.

Personally I've been thinking of having a Socket.io service on it's own server, something like a $5 droplet from Digital Ocean. Then use that to handle push notifications for a website in a similar implementation that you described. Right now it's just an idea, so I really would have to test it out to even find if it would work.

1 points

Well, I'll probably get a few public lashings for it, but I honestly liked the window decorators from that time. If I'm not mistaken, that's the Wombat Black window theme, right? I still like that theme and if I could get it on Gnome 3, I probably would.

5 points

No need to forgive, your are correct in that association between them. Just like an array you have a key-value system, but I won't say "key-value pair" because as you have already shown, there is more to a route than just the uri and the controller method.

To be honest, I can't think of a case when multiple end-points would all call the same controller method but not use the same uri or named route. It really doesn't make sense to me to have that particular use case at all. I can see where you're coming from, but it seems to be such a fringe case that it shouldn't be a concern.

Named routes are an alias within your application. An easy way to think of using them is as an internal shortcut so you don't have to remember the uri or deal with namespacing issues as well as the right controller and method name.

2 points

TL;DR: When you first run a request, part of the magic of the framework is that based on your routes file, a list of valid actions are stored in memory to be available for later use. Based on this quick reference list, when you call action('foo') it will check this list and return the url and associated controller method to fire off.

Sources: /vendor/IlluminateRouting/UrlGenerator.php /vendor/Illuminate/Routing/RouteCollection.php

In UrlGenerator, roughly 540 lines in, there is the action method. It is pretty basic and all it does is check for a proper namespace then it will see if the action you requested is in the list described above. If it is there, it calls the associated controller method. If not, an exception is thrown.

The method that it calls to check if the action is valid is the getByAction method of the RouteCollection class. This method simply checks an array property of it's class for the action, returns null if it isn't found. Reading the inline comments of addLookups in the same file gives a reference to that the array is added to every time a url is requested. Running the artisan command optimize also populates this list by reading all available routes in the routes file.

3 points

While I can definitely see how this would work, it really doesn't fit well with the paradigm I have chosen for how I structure and what opinions I have.

This does raise a question for me, in your base class how do you define the model fields used in your create/update? I'm guessing there is some function you use to return a list of them or do you just pass them in using 'new Model($inputData)' ?

1 points

It doesn't remove the auth middleware, but here is a list of what it does remove:

app/Http/Controllers/Auth/AuthController.php
app/Http/Controllers/Auth/PasswordController.php
app/Http/Controllers/HomeController.php
app/Services/Registrar.php
database/migrations/2014_10_12_000000_create_users_table.php
database/migrations/2014_10_12_100000_create_password_resets_table.php
public/css/app.css
public/fonts/*
resources/assets/less/*
resources/views/app.blade.php
resources/views/auth/login.blade.php
resources/views/auth/password.blade.php
resources/views/auth/register.blade.php
resources/views/auth/reset.blade.php
resources/views/emails/password.blade.php
resources/views/home.blade.php

And here is a list of the files modified that may reference any of those deleted files or anything in them:

app/Http/routes.php
app/Providers/AppServiceProvider.php
resources/assets/less/app.less

Source: I did a laravel new myapp, did a git commit, ran artisan fresh, then got the git status for changes to the repo.

1 points

My rule of thumb is this: use a trait when you have methods that will be identical among multiple classes but don't work we'll as a class on their own.

As an example, each of my repository files will interact with with my database using Eloquent. I know that means each repository class will have a method for getting all, finding by an id, patching a single field, and deleting but they can be identical except for the Eloquent model name. Those methods don't work well as a class in their current form because the context of each depends on which model I'm using, so I would use a trait. The trait would consist of one helper method to determine the correct model name (which Laravel has a built-in method to make it really simple), then the four methods to interact with the database. Now all I have to worry about when creating a repository class is to pull in the trait and write the create and update methods.

1 points

Something that was done where I work was to use a trait for a lot of the common methods for our Repository files. In some of the methods where eager loading could be used we simply do something like this:

public function all(array $eagerLoad = [])
{
    return Model::with($eagerLoad)->get();
}

And it does the job for us. All we have to do now is use the trait in any repository and it's all setup. Now when we call the all method from the repository in our controller:

public function getAll()
{
    return $this->repository->all(['first', 'second']);
}
1 points

That completely sucks, and I've been in a similar situation before. My advice to you, leave if you can. Lead developers that feel things like testing are new fads that will fade, get away from them. It will only hurt you.

My two cent story:

About two years ago I started at a place that was 45 miles from my house because it was all I could find. They brought me in, I passed all their little tests, then the subject of my commute came up. I told them I needed something (I had been unemployed for a few months) and that I understood that I was still expected to put in 8 hours on top of my commute. I asked about the possibility of working a day per week from home after I had been there long enough. They seemed really open to it.

I finally get my hands into their code base, and it made my brain melt like I had just opened the Ark of the Covenant from Indiana Jones. "What. The. *%$!. Is. This?!!" I mumbled. Rather than use a framework like CakePHP or Laravel, the lead developer had opted to just write a bunch of files everywhere. No framework. They really weren't even grouped into directories based on their purpose. It was just variations on a naming convention of his own design, almost all of it crammed into a single directory. I figured, "I'll deal with it for a few months then bring up a framework and testing, I need to earn my stripes before I criticize them openly." Sure enough, about 2 months later, I brought it up.

"Frameworks are too restrictive, they don't allow us to do what we want." Slight paraphrasing because of memory, but that's almost exactly what he said. I couldn't believe what I heard. So I dropped it, but at the next meeting with the CEO (small company, programming team of 3 people including myself), I brought it up after complaints of deadlines being altered again. I suggested that a framework could speed up production, that I had two in mind but I'm open to finding one that works for everyone. The CEO seemed really excited at the idea of it. When lead dev said that they wouldn't work, I politely apologized saying, "I'm sorry but I don't understand. I wasn't here when the decision was made, could you tell me how they were too restrictive and what they prevented you from doing?" Time for this guy to quantify his reasons, and sure enough, he had nothing. I proposed I spend my lunch break, so not on their time, finding a framework and producing an test case showing what took lead dev a few days to do I could do on my lunch break.

Even after showing them both what I had come up with, even after the CEO realizing that what he thought would be a month of work could be done in a week, even after showing lead dev that the framework isn't prohibiting what he wants at all, he just didn't know how to do it, I was still shutdown with placated remarks. Nothing changed, and I found out how much deeper that rabbit hole went. Database calls that brought in over 100 columns from a single table to use 3. No caching. Commenting out huge chunks of code, in spite of using git, because "What if I need to put it back in?". I tried to bring up concerns I had with the CEO, and in his office he was over-the-top understanding and accepting of what I had to say. He asked me to write up proposals of what we could change and how it would benefit us all. The other developer and I both had complaints about the lead dev, and both were shut down. I began to suspect that there was some personal relationship (such as a family friend, or lead dev was seen as a father figure because he was much older) between the lead dev and CEO. And I felt like that was protecting the lead dev.

I'm sure I pissed him off a ton, because I refused to work more than 8 hours a day on a salary position with no compensation for the extra time. I did have an attitude at times when I was pressed about it, they tried to guilt me into it. One time I was called into a private meeting with the lead dev. He tried to give me some advice that boiled down to, "start working extra or you'll have consequences". I asked him if I had been at work for the required 8 hours. He kept saying that salaried meant I sometimes had to work more, and I always replied that it also meant sometimes I got to work less, which was an absolute rarity. I eventually got written up for BS reasons, so I left. I'm sure I could have handled it better, and I realize now I was self-medicating with energy drinks and soda which probably gave me some mood issues. I had to sign an NDA and non-compete, which the non-compete expires next year. I've been tempted to research them next year to see how their progress is, and also begin developing a competitor to them. I've thought about it, but I'm being very careful not to do anything about it until the non-compete expires.

2 points

Yes it is for use in the query, but I was suggesting to structure the query to put the work on your database rather than being part of the logic in your controller (or repository, or whatever you are using). You could even use a whereRaw if you had to.

This is just my opinion, because I've found that it can be easier for me to keep tthe logic with or near what it is being performed on. In this case, it be advantageous to put that work into MySQL/PostgreSQL rather than in PHP/Laravel.

1 points

Awesome, thanks for the tip! I'll try that out now.

We are using the DB module for some (see|dontSee)InDatabase stuff, and from what we could tell it was the sanest way to accomplish what we were trying to check for during the test.

1 points

I am using the REST module to do it as a Web Service, and I've already set the memory option. Limiting it to below what ends up being the required amount will cause a large column of "Error" with a red background then a stack trace for each error. Not really pretty, but I know that's not Codeception's fault. It's my fault for writing tests in a way that requires nearly 2Gb of memory.

1 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.