/wdg/ - Web Development General

Previous
>Free beginner resources to get started
Get a good understanding of HTML, CSS and JavaScript.
developer.mozilla.org/en-US/docs/Learn - a good introduction (independent of your browser choice)
freecodecamp.com
codecademy.com
hackr.io

>Further resources
developer.mozilla.org/en-US/docs/Web - excellent documentation for HTML, CSS & JS
github.com/kamranahmedse/developer-roadmap - Frontend+Backend learner-path suggestions
youtube.com/watch?v=Zftx68K-1D4

jsfiddle.net - Use this and post a link, if you need help with your HTML/CSS/JS
3v4l.org/ - Use this and post a link, if you need help with PHP/HackLang

>PHP resources
pastebin.com/gfBPg24A

Attached: wdg.png (822x552, 814K)

Other urls found in this thread:

quoteworkshop.com/#pricing
codepen.io/S1eB/pen/BOvPee
w3schools.com/howto/howto_website.asp
secure.php.net/manual/en/ref.pdo-sqlite.php
secure.php.net/manual/en/features.commandline.webserver.php
wiki.php.net/rfc/typed_properties_v2
externals.io/message/102415
pastebin.com/93UTiw4L
secure.php.net/manual/en/function.parse-url.php
github.com/ssola/python-flask-microservice
github.com/leocavalcante/siler
github.com/lstrojny/functional-php
wiki.php.net/rfc/static_class_constructor
php.net/manual/en/array.sorting.php
twitter.com/SFWRedditVideos

answering php related questions.

oh no no no no

I'm going to be working on a social media business.

I'm going to use command line tools to create graphical content that businesses can post to social media. My idea is similar to
quoteworkshop.com/#pricing

Where I make tools to mass produce content. I will then look on instagram for a company that posts freqneuntly. I will make 100 branded images for them, post them to a website. Share the link with them and offer to sell them the unwatermarked versions for ~$150.

i made the previous 5 threads, i came back home to find the previous one archived so i made this, didn't notice that someone made it, sorry i guess ?

Yours is better, the thumbnail helps identification in the catalogue. I will post here.

delete it

Just startted a webdev course, what exactly is the point of php? And why not python or js?

The point of php is to be irrelevant.

Out of all the scripting languages it was literally born to fill a void, becoming a jack of all trades, now better stuff has come along that specialize in certain fields and the time has come to take php out back.

But yeah technically it's a server side scripting language, it compiles automagically whenever you edit the source and is meant to handle and process incomming requests on your page like forms, logins etc. If you want to give it a spin try WAMP or LAMP if that shit is still around.

>WAMP or LAMP if that shit is still around
it is

Anons, how do I get svg to maintain their aspect ratio when the browser is resized in a CSS grid.

Here is and example, to picture is a .svg and bottom is a png. When you shrink the browser the png maintains it's aspect ratio while the svg shrinks.

codepen.io/S1eB/pen/BOvPee

Why does everybody hate you so much? Is it you or your preference of programming?

promoting PHP + being a namefag, two in one

not everybody hates him though

What's wrong with PHP?

These days it's pretty ok I guess, but it used to be notoriously bad, no real surprise to anyone since the developer himself said that he didn't like programming much and that he preferred quick and dirty solutions to investing time and effort.

Bonus funpost: google the following
php-a-fractal-of-bad-design

For a given Single Page Application, is it horrible to store state serverside?

the PHP community are improving the language after a decade of shitty code and broken functions.
PHP 7 brings new stuff to the table and fix a lot of stuff in the code.

Have you tried using an svg element instead of an img one?

>svg element

Sorted it by adding the height to the html

nope

How is PHP these days actually? Does it do something particularly well? Or is it more for the people, who for some reason, don't want to or can't leave the PHP compound.

Anyone here getting this warning out of nowhere while using React and React Router?

Warning: Failed prop type: Invalid prop `component` of type `object` supplied to `Route`, expected `function

Just updated to React 16.4, I'm sure this wasn't here before

Doing this triggers it

But passing a function doesn't
Hello} />


This doesn't work, though
SomeComponent} />

Make sure that some-component are all valid React components.

I've heard Asp.net is good thoughts?

Attached: madoka-magica-crying-loli-tears.jpg (3840x2160, 732K)

shouldn't it be ``?

The whole .NET framework is very enjoyable to use.
C# is a good language, very common in "enterprise" environments, and the tooling is excellent (you may argue that's slow, but alt+enter-and-right-click-on-squiggles driven development is totally worth it).
You'll most likely bound to use other Microsoft, proprietary tools, but if your objective is just having a decently paid job doing internal LOB system development, then it's quite nice.
Don't expect hard development challenges or motivated colleagues though. In many places, they still use waterfall, and in even more, office politics is a very real thing you have to deal with.

ASP.NET Core is good

Ugh, people still use water fall in industry? Shy on earth isn't everyone using a modular incremental build system with groups of teams using the agile workflow? it is THE BEST way to develop projects.

there are cases you can't use the agile workflow on everything, m8

That's why you use a hybrid of agile and incremental, and all your sprints simply become your modular components and when you design your architecture right you give each team a sprint for a different module that needs to be developed. Straight agile kinda sucks imo, but with proper architecture and slightly more flexible sprint lengths depending on the module you are making, it rocks.

How are webpages really made these days? I took a ‘webpage design’ class once and we basically learned how to write html but i never really felt like thats how webpages are made. It felt really incomplete. If I wanted to create webpages for small businesses around town. Whats the best method of actually doing this. What do I need to learn.

This is how webpages are made.

index.html


Hello World
OP is always a faggot


This is a web page
OP is always a faggot

top kek much lel

You put HTML in the HTML folder
You manipulate that HTML with javascript
You style that HTML with CSS

Most web pages are made using wordpress or some other site generator where your job is 95% automated, and you just kind of plug in the correct info in the right spots, change some style to make it fit in properly etc.

w3schools.com/howto/howto_website.asp

>including html tags in the head
you are lacking CSS and javascript, and don't forget the server side, php mysql for starters

>not putting text in your header

you are confusing head with header, you absolute brainlet

That is where the header goes you faggot

Apologies for the noob question. What should I look into if I wish to buld a old-fashioned forum system running on Node? Maybe an imageboard system perhaps, like Jow Forums. A good ol' CRUD application. Not with PHP in any way, but with JavaScript. Like how do I use SQL with Node, and what npm packages should I look into installing?

Attached: Fotolia_76168997_S.jpg (719x668, 188K)

oh and the body isn't some structure tag, body is what encloses everything like header nav main and footer

like:

This is a web page
OP is always a faggot

top kek much lel

I've run into a difficult problem.
I have these objects from a JS library I'm using client-side that require configurations that depend on calculations from data server-side. What I want to do is somehow configure those objects server-side then simply create the object client-side. So basically do all those nasty calculations on the server before I even serve the page, then send down the configurations in a way that on the client-side I can just create the object and attach it to an element.
How do I accomplish this?
No frameworks. Vanilla JS on client, PHP on server.

Anyone got problems with npmjs.com?

Attached: bad_vibes.jpg (500x346, 25K)

watchu mean bb

accidentally fucked up with npm publishing some changes (package.json had a private package set to file:../{{local_dir}} instead of the npm version and we accidentally published it as that, it got corrected but shit man)

Attached: Screenshot from 2018-09-19 19-06-04.png (2492x1344, 223K)

>npmjs.com
works for me

ajax call to a php script that does the calculations...

yeah thats what I was thinking. throw a script block at the end that immediately makes an ajax call to get some json containing configurations, then create my object

>why not python or js?
what's the point of using python or js ? php can have a better performance and was meant to be used for the web.
>WAMP or LAMP
no, just no.
you don't need them, for a database, you can just use PDOSqlite ( bundled with PHP ) , for a development web server, php have its own built-in web server since 5.4.
PDOSqlite :secure.php.net/manual/en/ref.pdo-sqlite.php
php built-in web server : secure.php.net/manual/en/features.commandline.webserver.php
see : and nothing
well if you are referring to me, i never said that i don't like programming much , i love it
>fractal of bad design
the article is outdated, most of it is invalid nowadays, look for more recent resources please, and i will happily gone in debate over it.
php now have a package manager, modern frameworks, improved security ( in 2018, it had only 11 core security issues, while java had over 45 ), you can now do async in php using swoole or a pure php implementations such as ReactPHP, AMP... etc, you can also use any of these implementation to create a http/websockets server in seconds, php engine ( zend engine ) was rewritten from the ground for php 7, its twice as fast and uses half the resources, type hinting is now a thing in php, you can also declare strict typing ( you can read more about that in the official php website ), in 7.4 php is gonna have typed properties ( see : wiki.php.net/rfc/typed_properties_v2 ), php 8 is gonna have a JIT Compiler and much more.

in case anyone is interested in what's coming in php 8 : externals.io/message/102415

>well if you are referring to me, i never said that i don't like programming much , i love it
He's talking about the creator of PHP, Rasmus Lerdorf, who I think said that in one interview or another.

as someone who hates spending time on web design, what's the easiest CSS framework to get HTML presentable as fast as possible? bootstrap? I don't care if it looks generic as long as the result is usable.

i don't recall rasmus saying that, but at some point ( first when php was a templating language ) he didn't like the idea adding features to it until it became a programming language, the engine at the point was a mess, until andi and zeev rewrite the engine as Zend Engine ( ze from zeev and nd from andi )

I remember installing a javascript addon for VS code a while ago that added semicolons and swapped "" for '' like import something from "something" to 'something', does anyone know the name? I formated my PC and can't find it anymore

>implying people defend Java

i was just giving an example for those who say php is insecure. :)

bootstrap will just give you rounded corners on everything and make sure it looks kind-of-sort-of the same on every device.

define "presentable"
if you want to just make a layout for one device and you don't really care about how it looks as long as it conveys the information it needs, just write the CSS yourself. Use grid and flexbox.

Anyone want a free website or web app? It has to be something cool/fun and I get to dictate the tech stack. We can chat about it over discord or Kik or something.

lol

Yes. Bootstrap or Bulma will get you there. Probably other options as well but both of them are quite popular and very supported. Also lesser known alternatives like Lit which are pretty great too. Bootstrap comes with JS, Bulma is exclusively CSS and requires you bring your own JS if you want things like carousels.
But regardless, you're going to have to learn just how classes are used in each system, so like a day of getting it and you'll be good to go.

Either way, all of them will be MUCH more usable across numerous devices and browsers than running your own CSS if you hate CSS/are a backend person/etc.

why dont you just suck my dick already queer

What is the equivalent of getElementsByTagName but for css? I wanted to replace a background-image url, the script I use works for and similar tags but I can't find a way to make it work with css.

What?
>I want to replace the background-image CSS attribute for a given class
No
You want to change a given element's CSS class given some change in state.

That's disgusting. I'm disgusted.

>getElementsByTagName but for css
It's literally just the tag name. Doing
getElementsByClassName('h1')
selects the same set of elements as the CSS
h1 {
/* ... */
}


>I wanted to replace a background-image url
What do you mean by "replace"? Are you overriding an existing CSS rule, or are you changing it when something happens?

This (Jow Forums won't let me post it here):
pastebin.com/93UTiw4L

Naturally, it doesn't work because it's a tricky element that doesn't generate an tag. This works with normal elements, I've been using this method on other sites so there should be no errors.

Overriding I guess, like above.

dude there's a better way to do that.
You could have used a hosts file to redirect to an HTTP server serving pictures of carrots
You could have used a custom DNS server that routes everything to the same HTTP server

Attached: 1oxzE.png (465x360, 88K)

I thought about the hosts file but I'm not sure it can handle individual directories, blocking i.4cdn.org whole isn't good, all normal images will disappear too. Is it really impossible to make a regex script that looks for specific values in css files?

Thanks. didn't know about bulma, might go with that since I'm writing my own JS anyway.

>profile says im a fresh graduate
why the fuck are these recruiters contacting me for senior positions? does senior not mean what it's used to?

Attached: 1334329164853.jpg (366x380, 18K)

Ohhhhh, I get it, you actually want to query the source stylesheet itself, like you would with HTML.

Yeah, that's not a thing; you can't "select" elements by what CSS they already have applied to them*. And there's no easy way to search the stylesheet itself. You'd have to load it yourself (assuming you have a same-origin exception), search through it, and regex the URLs to your own, then insert your modified stylesheet preferably directly after the spot where the original is loaded.

Anyway, this CSS works for me for removing ads on Jow Forums:
.adg-rects {
display: none;
}


*unless it's actually inside a style attribute, but that's probably not the case

>there's no easy way to search the stylesheet itself. You'd have to load it yourself (assuming you have a same-origin exception), search through it, and regex
I also thought of doing that but my power level just isn't high enough yet.

>adg-rects
For some reason I didn't notice there was another above. Thanks, this will definitely get rid of that gross ad... I wish Hiro would keep them 2D-related at least, I just finished dinner for Pete's sake.

Maybe the job doesn't have many requirements? senior also implies graduate.

Attached: 1393438140456.jpg (1083x720, 179K)

>senior also implies graduate.
where do you live? I've never heard it used like this in burgerland

I could be wrong, I'm ESL but in my country people refer to graduates older than oneself as seniors if they've graduated from the same branch, so technically you're a senior to all those whop will graduate after you and those that are still studying.

That's valid in some cases, like "he's senior to me" would mean that the person in question is older or has more experience than you.

But in the case of jobs, generally the fresh graduate in the workplace is one of the younger people, and therefore would be "junior" to most of his coworkers. I would say to be a senior, you have to have at least some full-time experience in the industry. And I think people putting "senior" in the job description agree with this definition at least in part.

I agree with that the recruiter is probably fucking up.

This website is fucking around with me and blocking my userscripts from working.

I've have a simple click script like this in Tampermonkey
function redClick()
{
document.getElementById("middleTable").getElementsByClassName("red_button")[0].click();
}
But it's somehow blocked by the website.

Any hints as to what I can to get around it?

Attached: 1353624244413.png (231x234, 4K)

Don't die.

Attached: 1268024659522.jpg (500x375, 125K)

That's a lie. All of those are rendered obsolete when css grid, flex box, and media queries exist. There's no reason to ever use a css framework anymore

>somehow blocked by the website

in what way? is it the content security policy header doing it?

I'm not sure which way, this is on a testing server so they are probably experimenting with something.

All I can see is the CSS structure hasn't changed, the ID and Class names remain exactly the same.
And the userscript is running, I can see it active in the Tampermonkey menu, but it doesn't have the same effect like outside of the test server. It's like the userscript is ignored.

Something wacky is going on.

What's the proper javascript syntax/regex to grab the room name(room5) in mysite.com/r/room5

>You solve a problem that you've been stuck on for a few days now
Love it, bros. LOVE IT.

Attached: ghost.png (500x374, 270K)

>Salesforce question
How would I go about writing an IF statement for SOQL?

I have a .php file with a $query, I basically am looking for something like this:

if (a == b) {
$query = "SELECT etc blablabla WHERE blabla";
} else if (a == c) {
$query = "SELECT etc blablabla WHERE blabla";
}

Attached: programming.png (1080x718, 169K)

keep going

I would probably just do
var url = 'mysite.com/r/room5';
var urlParts = url.split('/'); // ['mysite.com', 'r', 'room5']
var roomName = urlParts[urlParts.length - 1]; // last element


There's probably cleaner way to do it with regex, but whatever.

I have to make my own microservice at work for a new product we're working on. It need to be in Python.
I only know Django but is it worth learning Flask for a smaller project?

doesn't js have a url parse function ? some like this ( secure.php.net/manual/en/function.parse-url.php ), even if it doesn't someone probably made it into an npm package already.

github.com/ssola/python-flask-microservice

>what's the point of using python or js ?
Ew no. PHP is tolerable and certainly more sane than some idiotic craplang like Java, but still sucks.

- No actual module system
- Because of the above, have to package everything inside classes
- ...but class variables have some kind of retarded limited initialization syntax so you can't just write your static variables freely inside the class, you gotta declare them and then specifically write an initializer function to initialize them and call it
- Array vs object relationships are a hot mess. Why on earth are they the same construct?
- ...and then objects and dicts (arrays) are separate constructs with different syntax, even though they're practically identical concepts and separating them provides absolutely no benefit, only inconveniences the programmer
- Closures suck, you have to explicitly type the RSI-inducing &$variable atrocity for every variable you wanna capture
- ...about that, how are they STILL too incompetent to get rid of the $variables?
- Arrays cause PHP to shit itself if you happen to refer to a key that doesn't have a value associated with it, who knows how they thought this was a good default behavior
- No actual in-built async at all

I could come up with more points too.

Wat do if i'm blocked by a bunch of pull requests?

I literally cannot continue my development without these PR's but my reviewers are soooooo busy and cannot set anyone else to review. They ignored me when i told them this, should i waste my time on Jow Forums?

>No actual module system
we have extensions, there totally 0 need for modules and php doesn't need it
>Because of the above, have to package everything inside classes
not really, we use namespaces, there's no need of classes.
for example, take a look at this framework : github.com/leocavalcante/siler
it doesn't use any OOP, it 100% functional programming
here's another package : github.com/lstrojny/functional-php
>class variables have some kind of retarded limited initialization syntax so you can't just write your static variables freely inside the class, you gotta declare them and then specifically write an initializer function to initialize them and call it
yes, that how php works and static classes are rarely used, but there's an rfc for that :
wiki.php.net/rfc/static_class_constructor
i don't think its gonna be accepted and i never needed it.
> Array vs object relationships are a hot mess. Why on earth are they the same construct?
i don't really understand this, can you explain more ? maybe give some examples ?
>and then objects and dicts (arrays) are separate constructs with different syntax, even though they're practically identical concepts and separating them provides absolutely no benefit, only inconveniences the programmer
i don't see how arrays and objects in php are the same, as above, please explain more.
>about that, how are they STILL too incompetent to get rid of the $variables?
lets say we remove the '$' today, every website/package is not gonna work, we used to it, that's how php variables are written. its not gonna change.

...

> Arrays cause PHP to shit itself if you happen to refer to a key that doesn't have a value associated with it, who knows how they thought this was a good default behavior
again, i don't really understand this clearly, but i think you mean something like this :
$array = [];

$a = $array['a']; // error

in this case you are referring to a key that doesn't exist, ofc its an error, but in php 7, you can always add a fallback :
$array = [];

$a = $array['a'] ?? 'default value';
// same as doing this in php 5.x
$a = isset($array['a']) ? $array['a'] : 'default value';

desu, i never seen someone complain about this and i don't see what else is php supposed to do, return null maybe ? ugh

>No actual in-built async at all
will there's third-party packages/extensions, php needs async and i agree with you in that. that's why its coming in php 8 :) you can see this : externals.io/message/102415

i would like to add that you can do async currently in php without using a package like AMP or ReactPHP ( ps : both are written 100% in php ), just like they did it, using generators
also, php have some built-in async functions for dealing with resources and mysql databases

>we have extensions, there totally 0 need for modules and php doesn't need it
Extensions? How are those a replacement for a normal module system where you can import code from file x and have it namespaced?
>not really, we use namespaces, there's no need of classes.
Far as I understand, you can't use them to define variables or complex constants?
>for example, take a look at this framework : github.com/leocavalcante/siler
>github.com/lstrojny/functional-php
Well, looks cool on a first glance
>yes, that how php works and static classes are rarely used, but there's an rfc for that :
Good, maybe they could get off their asses and implement it. There's several good features I've seen they've had as RFCs for years.
>i don't really understand this, can you explain more ? maybe give some examples ?
php.net/manual/en/array.sorting.php
Just look at this. You wouldn't need usort, uasort and uksort if you didn't introduce a pointless implicit order to array key-value pairs. It's the wrong abstraction. JS does it right by using maps in the background but exposing a regular array API to the programmer, instead of this monstrosity.
>i don't see how arrays and objects in php are the same, as above, please explain more.
What functionality do objects have over arrays? Why is the distinction needed?
>lets say we remove the '$' today, every website/package is not gonna work, we used to it, that's how php variables are written. its not gonna change.
They could make it optional.

>ofc its an error
Why? Querying if a key is in a dict doesn't cause a full-blown crash in any other language. Except maybe a segfault C, but that can be forgiven since C is low-level and treats arrays as mere stack pointers, PHP is supposed to be high-level.

Like I said PHP is not bad but it's not exactly good either.

>Why? Querying if a key is in a dict doesn't cause a full-blown crash in any other language. Except maybe a segfault C, but that can be forgiven since C is low-level and treats arrays as mere stack pointers, PHP is supposed to be high-level.
>Just look at this. You wouldn't need usort, uasort and uksort if you didn't introduce a pointless implicit order to array key-value pairs. It's the wrong abstraction. JS does it right by using maps in the background but exposing a regular array API to the programmer, instead of this monstrosity.
>Just look at this. You wouldn't need usort, uasort and uksort if you didn't introduce a pointless implicit order to array key-value pairs. It's the wrong abstraction. JS does it right by using maps in the background but exposing a regular array API to the programmer, instead of this monstrosity.
ARRAYS IN PHP ARE HASHMAPS !
you can't declare constants inside arrays, you can's have methods, or at least methods visibility, you can't have namespaced variables

>They could make it optional.
there 0 need for that, that's how the language syntax is.
>Good, maybe they could get off their asses and implement it. There's several good features I've seen they've had as RFCs for years.
all RFCs ( or most ) are already implemented, including that one, however the php internals have to vote for it, most of are involved in the modern php ecosystem and will take the community prospective on it and if it fits in the next release, currently its not gonna be accepted on php 7.3 ( php 7.3 is feature freeze now ) and not gonna be accepted on 7.4 ( 7.4 is a deprecation version, adding deprecation errors for the functions / features that are gonna be removed in the next release which is php 8 ), maybe its gonna be in php 8.0

>Extensions? How are those a replacement for a normal module system where you can import code from file x and have it namespaced?
you can packges for that, constants, classes, functions can be namespaced in php but not variables, but you can use something like a container
how ever, a package can declare a variable inside the global namespace but we try to avoid messing the global namespace in php, for example in zend expressive 0 variables are declare in the global variable and the index.php looks like this :

i would like to note that 7.4 is gonna contain only 1 feature, and its the typed properties since the community kept on asking for it to be merged. wiki.php.net/rfc/typed_properties_v2

>ARRAYS IN PHP ARE HASHMAPS !
Yes and the problem is that they're ordered hashmaps, with an associated implicit key order. Makes it convoluted whether you're trying to sort an array by its values in a normal way, or change they key-value order. And then some array methods expect numeric arrays (ie lists in any other language) as arguments, others expect dicts (which are also arrays, yay).

>there 0 need for that, that's how the language syntax is.
I still don't see why they hate our fingers

Now this just seems like a big mess to me. Why not just have a normal file-based module system like any modern language?

and that's 1 more thing you can't do with arrays, also php objects are passed by reference everywhere for example :

Yeah I don't actively use PHP, I just occasionally maintain a backend written in it.

I understand that you can get used to this stuff but from a semantic perspective it's just wrong and not something I can just be ok with when there are other popular languages that don't have those warts. Namely JS and Python to some extent.

will i guess php classifies more with C/C++/Java/C# than Js and python
as i said, if you php developers know more about what's best for the language and its ecosystem, changes arrays behavior, adding modules and remove `$`, are not good for php in anyway or just useless ( e.g: modules ).
if you were actively using php you will see how is that. your points is just like me complain why python and js don't have the same behavior as php.