/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:

symfony.com
symfony.com/doc/master/bundles/SonataAdminBundle/index.html
api-platform.com/
designpatternsphp.readthedocs.io/en/latest/
phptherightway.com/pages/Design-Patterns.html
tutorialspoint.com/php/php_design_patterns.htm
medium.com/@ivorobioff/the-5-most-common-design-patterns-in-php-applications-7f33b6b7d8d6
security.symfony.com
symfony.com/doc/current/security/security_checker.html
designpatternsphp.readthedocs.io/en/latest/Creational/README.html
gonzalo123.com/2011/10/17/working-with-request-objects-in-php/
zendframework.github.io/zend-diactoros/overview/
symfony.com/doc/current/components/http_foundation.html
packagist.org/?query=psr7
3v4l.org/KeUdg
stackoverflow.com/a/39897872/7427482
b-ok.xyz/s/?q=Full-stack Vue,js 2 and Laravel 5
symfony.com/components/HttpFoundation
github.com/php/php-src/search?q=slave&unscoped_q=slave
antirez.com/news/122),
getuikit.com/docs/countdown
ionicframework.com/docs/intro/tutorial/
css-tricks.com/snippets/css/using-font-face/
twitter.com/SFWRedditGifs

Here to answer PHP related questions.

guise

Attached: 1518940490355.jpg (300x278, 22K)

why do we need a promise here?
function getCanvasBlob(canvas) {
return new Promise(function(resolve, reject) {
canvas.toBlob(function(blob) {
resolve(blob)
}, 'image/jpeg', 0.9) //mime, quality. can be image/png or image/webp also.
})
}

Python or Ruby?

>make a website
>and a twitter account to promote my website
>my twitter account is very popular and has many thousands of followers
>my website only has 2k uniques per month
sigh

What kind of site it is? And is the Twitter account purely just advertising?

Attached: chinese_cartoons.jpg (3508x2480, 1.56M)

Python.

Rails is decreasing in popularity and that's really the only thing Ruby has going for it. Meanwhile Python is still rocketing in popularity.

Also Django > Rails

Because .toBlob() is an async method. The first parameter of this method must be a callback function.

Thanks mate, I'll be switching to Python then.

Attached: 1522951030287.png (532x582, 514K)

Don't you die on me thread

getRndInteger = (min, max) => {
return Math.floor(Math.random() * (max - min + 1) ) + min;
}

What are some Laravel books for beginners? From what I found in google:
>Beginning Laravel: A beginner's guide to application development with Laravel 5.3
>Laravel 5.1 Beauty: Creating Beautiful Web Apps in Laravel 5.1
>Laravel: Up and Running: A Framework for Building Modern PHP Apps
>Laravel Application Development Cookbook
>Laravel Starter
>Laravel 5 Essentials
>Learning Laravel’s Eloquent
Which one Jow Forumsents?

Attached: 58480e35cef1014c0b5e4920.png (512x512, 12K)

are you being forced to use laravel by your company ? if not, learn something else.

i explained why laravel sucks before , you can see it in the previous thread :

>>are you being forced to use laravel by your company ? if not, learn something else.
Well not really, I'm at an apprenticeship and I have to design a kinda CMS where a user gets their info from other databases, makes documents, fill out forms and has views (configurations by administrators for regular users documents) and to keep their data well structured and move away from excel and paper.
I thought PHP and Laravel would be nice to learn since I'm starting to see job postings and fuzz about it.

Attached: h6C4FC8B2.jpg (500x373, 35K)

you are a project to do, choose the right tool for the long term, why do you have to look at what jobs are available ?

anyways, such project can be done with symfony, admin bundle, twig, doctrine

symfony framework bundle already comes with twig and doctrine bridges so you won't have to setup any of these.

symfony : symfony.com
admin bundle : symfony.com/doc/master/bundles/SonataAdminBundle/index.html

if you would like to use modern javascript framework ( such React or VueJS ) , i suggest you use the api platform ( api-platform.com/ ), its built on top of symfony and have a really nice documentation and tutorials.

note, if you learn symfony very well, it would be easy for you to learn laravel in few days, laravel is symfony but oversimplified to the point where it sucks.

alright thanks for your input

Attached: web_dev_languages.png (566x800, 549K)

>Switching to Python with all the SJW bullshit happening recently
Just learn Go or Kotlin

Can someone explain me about design patterns in PHP (I am still a learner)? I thought it was about UX stuff but it's actually something entirely different.
>Singleton
>Factory
>Observer

I'm not even joking, i was writing a detailed explanation for each of these design patterns, till somehow the fucking browser window closed

FUCK ME

anyways here's some links :
designpatternsphp.readthedocs.io/en/latest/ ( highly recommended )
phptherightway.com/pages/Design-Patterns.html ( recommended )
tutorialspoint.com/php/php_design_patterns.htm ( outdated )
medium.com/@ivorobioff/the-5-most-common-design-patterns-in-php-applications-7f33b6b7d8d6 ( ugh )

is any of this stuff applied in small/big projects?
Honestly it looks complicated

>is any of this stuff applied in small/big projects?
>its literally used in all frameworks
and that's why people should stop thinking CS degree is a meme
please kys ty

don't forget about sololearn.com you can learn a bunch of shit off of there for free

pic unrelated

Attached: qum6zdggxwj11.jpg (440x474, 30K)

>is any of this stuff applied in small/big projects?
yes, every framework nowadays apply those patterns, if you ever used zend expressive you'll notice it makes a high use of factories and you need to create a factory for each class

>Honestly it looks complicated
actually its not, at the beginning yes, it does but after a while you'll have a batter understanding of these patterns and you'll be applying them yourself in your next project.
i don't have a CS degree

Attached: Untitled.png (1366x768, 133K)

neat, thx user

how do you guys know the modules you install aren't malitious (including their own dependencies)?

Attached: npm.png (695x287, 5K)

I just got put on a new project and I am wondering if I should use a front end framework like Bootstrap or if I should just man up and learn the new CSS3 stuff. what do you guys recommend?

for php, we have this :
security.symfony.com
and this :
symfony.com/doc/current/security/security_checker.html

it does it for us.

Do i need to learn how and when to use all of them?

yes

please don't die.

not like this thread !

I use as few as possible. Also you should have a good CSP so potential malicious frontend dependencies can't exfiltrate users' data from your web app.

That's for security vulnerabilities found in innocent code, is referring to intentionally malicious code hidden in what seem to be innocuous dependencies.

not on my watch php bro

thanks bro

Attached: b485f2c9-cd3b-4828-9f00-818a8a2f6716.jpg (271x254, 13K)

So far I only understood the singleton and factory patternbut have no idea in what cases do you use these patterns at all

factories and singletons belong to the "Creational" design pattern
>In software engineering, creational design patterns are design patterns that deal with object creation >mechanisms, trying to create objects in a manner suitable to the situation. The basic form of object >creation could result in design problems or added complexity to the design. Creational design patterns >solve this problem by somehow controlling this object creation.
- designpatternsphp.readthedocs.io/en/latest/Creational/README.html

go there and read more, its explains it in details with examples, i'm really busy rn, sorry UwU

PHP:
If testing an empty string returns false (eg. using if statements), why should I use isset()? Is it only used for _POST/_GET?

this is how you should check if a string is empty :

if ('' === $string) {
// $string is empty :)
}


why use isset ? isset is used to determine if a variable is set and is not NULL.
mostly used on '$_GET', '$_POST' to check if the field is set
example:
if (isset($_GET['attr'])) {
$attr = $_GET['attr'];
} else {
$attr = 'default';
}

// since php 7, you can do this instead :
$attr = $_GET['attr'] ?? 'default';

another use of isset is to check if a variable is set :

$a = 1;
$b = 2;

var_dump(isset($a)); // true
var_dump(isset($b)); // true;
var_dump(isset($c)); // false !


if you are using $_GET and $_POST in your application , i recommend you stop doing that ! why ?
have a read : gonzalo123.com/2011/10/17/working-with-request-objects-in-php/

what do to use instead ? request / response objects !

examples :
// using zend diactoros
$request = Zend\Diactoros\ServerRequestFactory::fromGlobals();
// using symfony http-foundation
$request = Symfony\Component\HttpFoundation\Request::createFromGlobals();


zend diactoros : zendframework.github.io/zend-diactoros/overview/
symfony HTTP foundation : symfony.com/doc/current/components/http_foundation.html

i would recommend using zend diactoros ( symfony is great too ) cause it implements the PSR-7, which is used by so many php frameworks / projects, that means if you start later using any framework or library ( that have something to do with requests/responses you will likely find it using a PSR-7 implementation, so you can give it a zend diactoros object ) that implements PSR-7 in no time.

examples ( frameworks ) :
- zend framework
- zend expressive
- symfony ( using PSR-7 bridge )
- laravel ( using PSR-7 bridge )
- slim
- cakePHP

examples ( libraries ) :
- ReactPHP
- EasySwoole
- GuzzleHttp
- aura router
- fast route
- more : packagist.org/?query=psr7

Never. Patterns are for autists and result in unreadable code

>Patterns are for autists and result in unreadable code

Attached: e5upSHu.png (512x380, 216K)

I have a server with limited memory and I want to serve large files to a web browser, is there a way to send a file in chunks instead of loading the whole thing to memory before sending the http request? do browsers support getting files in chunks? is sending big images and web pages in such a way supported?

>tfw want to learn Angular and have been trying to learn it for nearly a month, but still can't manage to get a basic UI for a CRUD app up. Meanwhile It only took me 2 days to do it in Vue.

Is this fate /wdg/? Should I abandon Angular and join the chinks

Attached: 9B2x7mM.png (736x475, 128K)

IDE recommendations?

It depends on the language you're using

>mfw there are Creationals, Structural, Behaviorals and three non-classified extra patterns
Fucking hell

Attached: 1530032333746.jpg (1186x791, 201K)

yes you can use this for php, but i recommend you use zend diactoros or symfony http foundation, they handle it way much better, but i found this in stackoverflow, i fixed some issues with it and it should work fine : 3v4l.org/KeUdg

usage :
$response = new StreamResponse('path/to/file.mp4');
$response->stream();


original SO answer : stackoverflow.com/a/39897872/7427482

vue is cute uwu

for PHP i recommend using PhpStorm, nothing comes close to it, but its not cheap.

$response->send();**

I worked through `Full-stack Vue,js 2 and Laravel 5` and found it really good, it took me ~22 hours over a weekend and it really made a lot of things click around modern front end and back end (basically an API and and SPA), while also covering the basics of Larvavel (it didn't go too far in detail). Now I work with Django and React and a lot of knowledge carried over from that book.

Link: b-ok.xyz/s/?q=Full-stack Vue,js 2 and Laravel 5

second though, that was trash, use symfony streamed response :

$file = '/path/to/file.mp4';
$format = pathinfo($file, PATHINFO_EXTENSION);

return new Symfony\Component\HttpFoundation\StreamedResponse(
function () use ($file) {
readfile($file);
}, 200, array('Content-Type' => 'image/' . $format)
);


symfony.com/components/HttpFoundation

You mean that meme going around about the guy changing a couple of words in the documents? Most of those changes were better metaphors, for example changing master to server in the ssh section, master makes no sense w.r.t ssh.

Or is there some real SJW shit happening with Python? (Seriously I would like to know, I work with Python)

python removed master/slave terminology because it was "offensive"

its maintained by absolute faggots, just use perl.

JOIN PHP WE HAVE SLAVES

github.com/php/php-src/search?q=slave&unscoped_q=slave

Like I said, I've seen the meme.

* Have they made any changes to Python code (not documentation) because it was 'offensive' ?

* Have they changed master/slave to any worse metaphors?

Personally I agree with the Redis maintainer's views on this (antirez.com/news/122), we shouldn't have to change our work because it offends someone. That said even he is changing Redis slowly to move away from master/slave, it seems to be something hard to get away from.

On one hand I support the whole diversity thing in principle, I don't just want to work with white dudes. And I don't really care about words becoming 'not allowed' that happens, words are attached to emotions, you can't say nigger without stirring up people we all know that. But what does really bug me about the master/slave thing is Americans pushing their world view on the rest of us, like I get slave is a more emotive word in their country but they cannot grasp that it doesn't have that history anywhere else.

Thanks for the invite Herr PHP, but if I'm going to switch it'll be to Go

pls respond

Don't use fucking CSS frameworks period.
What are you, a codemonkey brainlet?

And while I'm on the topic, master slave is a terrible metaphor most of the time it's used. A slave DB doesn't obey the master, it replicates it and steps up if the master goes down, primary/replica makes much more sense. Sometimes master/slave is used instead of server/client, also wrong.

I automotive brake systems (and most hydraulics) you have a master and slave cylinder, this explains their relationship perfectly, the master creates some sort of control signal (hydraulic pressure in this case) and the slave does the work, one is useless without the other. I can think of no better words.

Serious question, I'm self taught and missed all that important CS stuff. Are there any software relationships that are best described by master/slave?

**This post is not an endorsement of changing thing because people are offended, offended people can fuck off and we should do the opposite of what they want. I just like talking about the words we use.

The problem isn't the words itself. It's the motive.

They tried to remove master/slave entirely for political reasons, which should fuck right off as that has nothing to do with software development.

Don't use Chrome or FF you brainlet, write your own browser.

Depends on the project, I'm working on a big project with 7 devs and a designer, the designer wants things a certain (custom) way, there would be little benefit to using a framework, so we write from scratch and it's extra work and cross browser testing.

Bootstrap 4 without JS (or Bulma) is a great framework, not too big and reasonably customisable (through sass or their online tool). It will help you get more done faster, it will push you towards helpful conventions, it has great documentation and examples. But it might not be the right tool for your project But it probably is, because you're probably not making anything groundbreaking, what you're doing has been done before (more or less) and that's okay, don't reinvent the wheel, do it simple and do it well.

I disagree with you slightly, banning words should be avoided but I think it's important to make people feel included and safe where reasonable.

If CS had developed earlier and had actual racial slurs in code, not some bs trigger word, like imagine if master/slave was white/nigger.

> "the white server has gone down, it's got a Trojan Kike, switch to a nigger server"
> "oh shit, the nigger server's down too"
> "dammit Dave I told you not to lock those niggers in the basement and forget about them, you have to check they're working every day"

That would be bad, there's a limit.

Most people seem to get into software because they ideological, they want to work on new things, push the word towards a better place. I wish we could redirect that energy to some actual positive change instead of arguing about words.

yo js zoomers, the php boomer need help

i'm using uikit css framework, it have the "countdown" component ( getuikit.com/docs/countdown ) which seems nice, in this project i'm not using vue or any other js frameworks and trying to minimize the use of js, beside uikit.

after the user registration , he's being redirected to '/welcome' a page where it says "welcome {{ username }}" and some other shit, anyways, i wanna redirect the year to the home page after few seconds from landing on "/welcome", is there a way to do that using the countdown component from uikit ? it seems like a i need to pass a time to the attribute and i don't wanna do that in the backend using twig cause the i wanna redirect the user after 5 seconds from the page being fully rendered, not since the server sent the response ( the page may take more than 5 seconds to render after the server sent the response in cause the user have a slow internet connection ), what i'm trying to say, can i insert the 'date' attribute using java-script ? how do i add an event listener to redirect the user after the time is over ?

this is the "welcome.twig" file :
{% extends '@layout/default.html.twig' %}

{% block title %}Welcome{% endblock %}

{% block css %}

{% endblock %}

{% block content %}



Welcome {{ user.getUsername() }}

Lorem ipsum dolor sit amet, cons....
You'll be redirected after ( this is where it should go )









{% endblock %}

{% block javascript %}
// javascript goes here
{% endblock %}

Why would someone put an expressjs application behind ngix?

just use bulma sweetie its the only sane css framework if you truly want to use as little JS as possible

nginx is being used as a load balancer?

i'm gonna need js later anyways, its not like i'm trying to avoid it at all, for now, i'm trying to solve this problem, how can add the date parameter with js !

I was writing a detailed example but my computer crashed, having hardware issues recently, ugh.

Basically just use history.pushState inside a setTimeout, look it up on Mdn its hella simple

Or now that I think about it maybe this is the sort of page you don't want to go back to, in that case use history.replace so the page they're being navigated from isn't saved in their history

ended up doing this ( the text says you will be redirected after few seconds ) :
let seconds = 5;
const countdown = function () {
seconds = seconds - 1;
if (seconds < 0) {
window.location = "{{ path('home') }}";
} else {
window.setTimeout(countdown, 1000);
}
};

countdown();

fuck this, i hate js
i'm going to sleep

Same but simpler

let seconds = 5;
function countdown() {
window.location = "{{ path('home') }}";
}
setTimeout(countdown, seconds * 1000);

Same but less

const seconds = 5;
setTimeout(() => window.location = "{{ path('home') }}", seconds * 1000)

trying to do something simple through a framework is so absurdly silly
like come on now

>visit website
>it's broken in some way
Nearly every time.

Justify your existence to me, please. Why shouldn't there be capital punishment for webfags?

So you just said that you dislike active record and you like the repository pattern. That's like, your opinion, man.

20 layers of abstraction and weird unmaintained frameworks backed by a bunch of hipsters.

You should use something like Nginx to serve static files instead. If you want to do authentication or handle other logic you can do it like this:

Nginx
location /protected/ {
internal;
alias /data/files/;
}


PHP (or any other language)
header("Content-Type: video/mp4");
header("X-Accel-Redirect: /protected/the_file.mp4");

>>it's broken in some way
>Justify your existence

My websites do what my customers' want them to do and they work in the browsers specified at the start of the project (usually IE11 and the main 4). Either you're on shithouse websites or the site wasn't made for your autistic browsing stack

I'm trying to add a font I made to my website but it is only shown to people who already have it installed,
Here is my code :
@font-face {
src: url('css/duf-webfont.woff2') format("woff2"),
url('css/duf-webfont.woff') format("woff"),
url('css/duf-webfont.ttf') format("opentype");
font-family: "duf";
}

What's the issue here?

no i'm gonna change the text every second, so ...
why would i use a framework just to do a countdown, jeez

that's not how you send big files with php

>want to learn Ionic
>can't find a complete tutorial

Attached: folder.jpg (500x500, 40K)

CHECKED

ionicframework.com/docs/intro/tutorial/

FAGGOT

could be a bad src url

check the inspector tools from your browser

see if it has any warning

don't listen to that idiot. Pick whatever you comfortable using and has a proper community.

>ionicframework.com/docs/intro/tutorial/
>text tutorial

Attached: 11-drake-hotline-bling.w710.h473.2x.jpg (1420x946, 56K)

> has a proper community.
< laravel

kys

brainlet here, use the thingy that is triggered on page load onjs. So on page load >countdown, on countdown > page switch

But I'm a brainlet maybe someone else has a better idea bout that.

I can myself see the font because I have it installed on my pc so I don't have any errors

Please teach me how to use 206 Partial Content, I'm reading an image file line by line and sending it, how should I format the http header?

Why you niggers keep using ES6 if that means it isn't going to be compatible with IEedge anyways? it's not the time for it yet, or am I missing something?

>implying i give a fuck if it doesn't works on ie or edge

so try with another font that you don't have installed

I'm already dead!

Attached: 181455__187_l.jpg (400x300, 24K)

css-tricks.com/snippets/css/using-font-face/

see if that makes any difference

Tried with google font and it worked, now where does this gets me?
Is there something wrong with my font?

it might be the url that is fucked up

do the following, pick a font that has all the different formats like the first example in don't install it in your browser, if it doesn't work you are messing the url, usually you put the fonts in a font folder which would be something like./fonts/myfont.extension

please