/wdg/ - Web Development General

Death to PHP!

Previous thread: > Discord
discord.gg/0qLTzz5potDFXfdT

>IRC Channel
#Sup Forumswdg @ irc.rizon.net
Web client: rizon.net/chat

>Learning material
codecademy.com/
bento.io/
programming-motherfucker.com/
github.com/vhf/free-programming-books/blob/master/free-programming-books.md
theodinproject.com/
freecodecamp.com/
codewars.com/
>Crockford on Javascript
youtube.com/playlist?list=PL7664379246A246CB

>Frontend development
github.com/dypsilon/frontend-dev-bookmarks

>Backend development
en.wikipedia.org/wiki/Comparison_of_web_application_frameworks

>Useful tools
pastebin.com/q5nB1Npt/
libraries.io/ - Discover new open source libraries, modules and frameworks and keep track of ones you depend upon.
developer.mozilla.org/en-US/docs/Web - Guides for HTML, CSS, JS, Web APIs & more.
programmableweb.com/ - List of public APIs

>NEET guide to web dev employment
pastebin.com/4YeJAUbT/

> How to get started
youtube.com/watch?v=pB0WvcxTbCA
Good videos on the channel too
youtube.com/channel/UCVTlvUkGslCV_h-nSAId8Sw

>cheap vps hosting in most western locations
lowendbox.com
digitalocean.com/
linode.com/
heroku.com/
leaseweb.com

Other urls found in this thread:

amazon.co.uk/gp/digital/fiona/thank-you
amazon.co.uk/gp/digital/fiona/clarification/purchased
twitter.com/AnonBabble

first for PHP

Second for Meteor and Ionic

Third for dragon dildos

I'm writing a personal project with Hack/HHVM and it's not too bad. It's nice to have something similar to structs.

But I still like go more than Hack.

>go
It is not the C++ killer it was supposed to be, but damn it's so easy to maintain idiomatic Go code.

How do I make callback properties with es6 classes? I've only used typescript before.
class Test {
public SomeEvent: (data) => void;

constructor() {
setTimeout(() => {
this.SomeEvent('event!');
}, 1000);
}
}

let test = new Test();
test.SomeEvent = (data) => {
alert(data);
};

es6 classes only seems to have getter properties or functions?

Same way you do in TS, but without the type annotations.
class Test {
constructor() {
setTimeout(() =>
this.SomeEvent('event!'),
1000);
}
}

let test = new Test();
test.SomeEvent = data =>
alert(data);

okay I see, thanks.
feels kind of weird using/setting a property without defining it first.

Class is a lie in js!
Learn classless oop!

Is there a web-centric programming language other than PHP?

meaning the language was built from the ground up for web.

I got drunk and learned grunt last night. I don't really remember much of it, but now I have a project set up with live reload, a few other neat plugins, and detailed notes full of wildly inappropriate metaphors.

Drunk me is an okay guy.

JavaScript

It can't do back-end stuff out of the box though.

NodeJS, senpai

that's not out of the box

>Current roman year
>single-threaded

It literally is though.

function obj(){
}

var copy = [];

for( i=0; i < 5; i++ ){
var copy[i] = new obj();
}


Why can't I create objects in a loop and then access them by copy[i]?

Thoughts on CodeKit?

because obj is a function and not an object? o.O

In all honesty, use TS, whenever you can. Some of the shit from earlier versions is stupid and redundant, but once they decided to become a superset of ES6/7, it became the best way to date of writing maintainable and robust JS code.

you calling the function within itself?

It's just syntactic sugar. Do you enjoy writing Foo.prototype.bar = () => ... all the time?

Obj() is an object constructor with several values. I want to create five different objects in a loop so as to get copy1, copy2, copy3, etc.

Why is doctrine the most awesome bloatware ever made?

Let me rephrase, a language that's built from the ground up to handle the fornt and back end without the need for any add-ons or modification.

whilst node.js is out of the box, because it is based on js, the back-end leaves something to be desired.

k

How do you like Symfony so far?

Never used it. Looks like a nice way to get off the ground quickly without having to learn a bunch of boring setup stuff though.

I haven't done much until now, but since 90% of web jobs in Switzerland require symfony I decided to give it a go.

It's very clean, logic, and nice to use. I did the error of using the latest stable instead of the lts, so many components don't work yet if I don't use their unstable branches. For example, I can't make the SonataAdminBundle work.

so far so good, actually.
Coming from Java btw, haven't done much web development n my life.

Sup nerds

I like CoffeeCup, but I'm poor. I want something similiar to it but 100% free as in gratis. Care to reccommend?

Pic unrelated

Is there a nodemon equivalent for Python?

I actually went from grunt to gulp to codekit. I've worked on relatively small projects lately and hated having 20+ node_modules folders.

Re-declare the "copy" variable in a different way? I'm way too sleepy to know what language syntax that is, but usually it needs to be able to accept arrays.

Oh fuck nevermind, didn't know nodemon works for both Python and Node. Was pleasantly surprised.

function obj(){
}

var copy = [];

for(var i=0; i < 5; i++ ){
copy.push(new obj());
}

So, is codekit faster to use than a gulpfile.js? Is it worth the 32 bucks? Is it as annoying as the webpage?

DQL is so fucking awesome

>fapping with other men

I haven't noticed any big drawbacks in performance. If by speed you mean setting up your project and actually start coding, then it is much faster. There is a new and less annoying version coming soon I think.

Well in the time you answered I downloaded it and found it's a really nice program. I can do the same stuff I do with gulp or grunt but also have a nice livereload and an url I can look in the mobile device. So thanks for the tip!
Maybe for more complex stuff gulp is still necessary but my workflow is really simple atm.

Why the fuck is Node such a pain in the ass.

I've got this in my scripts in package.json:
"build": "node ./node_modules/browserify/bin/cmd.js -t [ babelify ] src/app.js -o build/app.js",

When I run "npm build", it results in empty build/app.js file, but when I run that line manually from the command line, it outputs the correct code in app.js, what gives?

>Take a look at PHP RFCs for the first time
>Callable Typehinting, Pipe operator, named arguments, typed properties, traits implementing interfaces, nullables, reflectable attributes, generics, short lambda syntax...
>Holy shit, if those got implemented, the language would actually be pretty sweet!
>Eventually find out that those are basically all just bad copies from hack, which already has all of those
>Also find out that those require a 2/3+1 majority by the morons who call themselves "PHP Core dev" to be accepted
>Those morons already declined some, like short lambdas and C# style properties because it "could be confusing (To PHP developers)
>Those RFCs being implemented: Never ever

You know, I'm actually thinking about giving hack a try. It has the features I want, the performance I want and you don't have to wait for it to recompile after every change, like Java. Unlike PHP's devs, Facebook's dev team actually seems to know what makes a good language.
Does it already have proper IDEs, frameworks and community support?

You could make copy an object instead of an array.
If you want to use an array, you will need to call push instead of setting the index.

What is this SonataAdminBundle good for? I have used Symfony for almost a Year now, but I never used that.

it's a pre-made admin backend for basic CRUD stuff. It's great.

But what does it do? Automatically create list / details / edit / delete views for all your entities? That would indeed be quite cool.

I just launched a demo container on their site. Do they also allow clients to create their own pages by just clicking them together? Because that is EXACTLY what I need for an application that I'm currently working on. That is, if you can still give some specific rules for this websites and the forms it contains, if those forms are very specific and complex (you never know how bad form handling can get until you need to handle user-generated fields of any type, seriously).

>>Those morons already declined some, like short lambdas and C# style properties because it "could be confusing (To PHP developers)

Well they probably aren't wrong....

>But what does it do? Automatically create list / details / edit / delete views for all your entities? That would indeed be quite cool.
exactly this. And it's very customizable. Still, it has every needed default convention for most use cases.

I know. I mean, just look at PHP developers, holy shit. They actually think that their barebones OOP that is just a terrible clone of Java's is "complex" and "fleshed out".

>Why the fuck is Node such a pain in the ass
Flask is comfy as fuck brah, switch to Python.

I see. That's pretty cool then. Would save me a lot of time making those over and over again. Symfony's generatorBundle does a poor job once your entities get at least a tiny bit complex.

How well does this admin bundle handle entities that are "children" of other entities? For example, in my application, nearly all entities relate to one parent entity, which appears in the URL basically all the time. So for example, whenever I need to generate a URL to it, I don't just say generate('cockshit' ['id' => $id]); but generate('cockshit' ['parentIdentifier' => $parent->getIdentifier(), 'id' => $id]);

Symfony and its generators by itself don't handle this that well.

Oh, I'm using Flask extensively because I do backend stuff (although I'm not that much into web development) but I'm working on an "application" based on Electron that's from webdev standpoint could be called purely front-end, that's why I'm using node for development (so I can manage dependencies and build it for the "browser"). Still it's weird that the command fails through package.json script (with no error in stdout/stderr) but works fine when I execute it manually.

>It came out of an April Fool's joke but proved popular enough to make into a serious application in its own right

Jesus Christ, PHP is literally so awful that people have made april fools jokes that are better at handling web requests.

So I learned Laravel pretty good, but then discovered that there are literally no jobs, so now I'm learning rails. They're pretty similar so I'm thinking I should be able to pick it up quickly and hopefully get a job within the month.

Requesting sauce on the "better at handling web requests" part

I figured it out, apparently I need to use "npm run build" instead of "npm build", which is weird because "npm start" executes the script for "start", but "npm build" won't execute the build script, whatever.

>all that convoluted and bloated code to scrape porn websites

lmfao.

This. Just fucking write a single file Perl script in half an hour

My boss is an idiot and got his password to one of our shitty WordPress marketing sites phished or stolen. He made me log all log in attempts failed or otherwise and this is what I threw together. I almost never do anything flat file related with PHP so I just wanna make sure this isn't too shitty. Opinions?

function log_login($user, $username, $password) {
global $logpath;

if(!empty($username)) {
$logstr = date("m-d-Y G:i:s", time()) . ": $username" . '@' . $_SERVER['REMOTE_ADDR'];
$userobjclass = get_class($user);
$pwd = 'N/A';

if(!empty($_POST['pwd']))
$pwd = $_POST['pwd'];

if($userobjclass !== 'WP_User')
$logstr .= " (Failed w/ '$pwd')";

$logstr = htmlentities($logstr);

file_put_contents($logpath, "$logstr\n", FILE_APPEND);
return $user;
}
}

And here's a shitty little page to view the log so he can have peace of mind and let me do my non-WordPress shit in peace

global $logpath;

$logcleared = 0;
$logstr = "The login log is currently empty.";

if(!(empty($_POST['trusp_clearlog'])) && ($_POST['trusp_clearlog'] === '1')) {
if(file_exists($logpath))
unlink($logpath);

$logcleared = 1;
}
else {
if(file_exists($logpath))
$logstr = file_get_contents($logpath);
}
?>



Log cleared.


Login Logs

Well, he is a PHP developer.

Without a thick fat layer of abstraction like Symfony with Doctrine DBAL & ORM, this language can't do anything except creating serious vulnerabilities for your server, your company and your customers.

I'm glad I took the time to learn a little more about SQL than SELECT * FROM whatever -> filter everything client side. Our biggest application's code base has all raw SQL and one of our interview questions is asking what some of the more simple queries do. Almost everyone gets thrown off the second they see PDO and don't even bother to look at the actual query. Everyone else gets stuck on JOINs and sub queries. I'm going to have this job forever because literally all PHP devs are idiots

Yeah, me too. I didn't actually mean to insult you (even though I did, sorry for that), I just have terrible experience with fellow PHP developers and PHP as a language.

SQL injections are a serious issue. Why? Because they are so hard to avoid?
No. It's because PHP developers are fucking retards who simply have no idea WHATSOEVER. If you ever do string concatenation in a query and your alarm bells don't ring, then please quit your job, damn it...

Most people don't understand how easily injections are prevented via prepared statements. My boss doesn't believe me. He wants me to use a web application firewall for all my software because he believes that SQL injections could happen.
How? I never do fucking string concatenation in my queries. I also use a templating language that auto-escapes every variable (which basically every proper templating language [Thus, not PHP] does by default) and explicitly requires me to say "Yes, please, please give me the raw output from this variable" if I'm 100% sure that is clean.

Literally everything and everyone close to PHP is retarded. Those that are not are trying to get away from it.

>Wordpress

I'm so sorry user

>tfw Django job
lads this is the most fun I've had programming in 2 decades

I'm not a developer (but I am a information security guy)

every joe knows to do paremeritized queries in SQL, in every language, PHP especially

where do I start learning django provided I have almost no experience with python?

what programming experience do you have? In any case, you'll be learning both at the same time, but it's very batteries-included so it won't be too tough to get things together

just basic python & php

Yeah we still have a bunch of things left over from when our old "CTO" was still bossing me around. I want to transition all of our marketing shit to one of those static site generators, but I'm not sure how I'd implement some of our SEO tricks that do too much good to be lost in the transition. Its not that bad though. I had to go through hell last year replacing a bunch of shitty Pajeet tier plugins and themes with my own shit and since then its been pretty smooth. Every once in a while I need to actually write something new, and end up holding myself back from punching my monitor since WordPress's developer documentation is pure shit. Anything and everything you're looking for is a major version or two out of date or simply missing altogether

you're set. Start with the tutorials and make a blog using generic views

is there any particular tutorial you would recommend? what worries me the most is my code is usually pretty disgusting looking I'd like to learn how to make it nice and clean along the way instead of just mashing shit together

I'm not a PHP developer primarily and I'm not the guy who posted that porn site scraper so don't worry about it. I work with Perl primarily because I'm a rare breed of autist. I just happen to be better at PHP than everyone else we've interviewed, so I'm stuck maintaining our old PHP shit

What wonderful planet do you live on and how do I get there?

SEO is just literally reading google and bing and modifying your tags to have the proper data. And sitemaps.


And dude, all the competent new publications ar eswitching to build-based and static content now. It significantly lowers the cost of upkeep (db and app server gone ; only web server needed).

The official ones, and as long as your code is readable and makes sense, you shouldn't worry. Try not to abuse clever tricks (note that map, reduce, filter are important tricks) and it'll flow smoothly

Canada

Its not really up to me what we do SEO wise. My adderall addicted boss is a self proclaimed SEO "ninja" and while he lets me do whatever the fuck I want otherwise, anything marketing related has to be approved by him first. So I'm stuck spinning content and targeting location based results

I'm sorry...

you couldn't pay me to work with PHP

Ruby maybe,

PHP is just pajeet tier

Everything is pajeet tier to you morons.

Say what you want, but Pajeet still has a very clear definition. Sure, maybe it'll join the ranks of autism one day but for now its still a very targeted insult

I asked this in /dpt/ but they told me to come here.

So, here it is:

Sup Forums, I'm wondering if you can help me out a sec.
This is beyond my level of code as I'm new, but I want to create something (for GreaseMonkey) that will automatically close a certain type of website.

For example, say I'm buying shit on Amazon. I want it to automatically close when it's something like:

amazon.co.uk/gp/digital/fiona/thank-you [and everything that follows in the URL from that]
amazon.co.uk/gp/digital/fiona/clarification/purchased [and everything that follows in the URL from that]

What should I be looking at doing, or is there something like this already?

I seem to be spending a lot of time closing tabs for things after they've finished, but I can't just right click and 'close all', because not everything has finished.

Help?

Again, I don't work with PHP primarily. I just maintain old shit that's left over from when our old "CTO" was still in charge. There were a few months of hell where I had to replace all of our Pajeet-tier plugins and themes, but since then its been smooth sailing since I'm not a retard and can write shit that doesn't break with every WordPress update

Java + Spring and PHP without Laravel about sums it up

Pajeet tier is just a meme for "poo" tier

anyone can commit a pajeet tier, believe me

QUESTION

How long to learn rails if i know php + frameworks?

So instead of a DB you have all your data in a shit ton of files? How's that going to help anyone?

is there any prettier way to get a bunch of element references instead of putting them all into variables once?
maybe something where I don't have to give everything an id/class?

I want to avoid having to do this every time.
const buttonOk = document.getElementById('button-ok');
const buttonCancel = document.getElementById('button-cancel');
const buttonClose = document.getElementById('button-close');

it adds up.

You don't have to run a database server. I don't see how that isn't an advantage

REEEEEEEEEEEEEEEEEEEEEEEE

Now if only Laravel wasn't as slow as a snail stapled to a cardboard box, that bleeds network errors under the slightest load.

Then just use SQLite or LevelDB.

If you have a lot of records, running a local db for builds aint bad.

Ideally your builder should know when to regenerate the entire index or not (based on changes)

Write a userscript that runs on all amazon pages and calls window.close(), when need be.

And roll my own CMS around it? Use something less popular and likely less supported than Wordpress? No thanks, I'd rather just use a static site generator.

By the way, I'm already using WordPress. Keep track of the convo

Or you could just use another language with another framework. I only claimed Laravel was one of the few ways to write non-Pajeet code in PHP.

Seems pretty straightforward. What are you having difficulty with?

indexOf("clarification/purchased"); window.close();

I don't mean to discriminate, but is PHP the only language taught in India or something? It's kike they all default to it.